Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
62c77d0a
authored
Jun 29, 2016
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
base_c: added function to set thread priority, implemented for windows only for now
parent
9bbf0e67
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
base_c/include/embb/base/c/thread.h
+15
-0
base_c/src/thread.c
+45
-0
No files found.
base_c/include/embb/base/c/thread.h
View file @
62c77d0a
...
...
@@ -56,6 +56,16 @@ extern "C" {
typedef
opaque_type
embb_thread_t
;
#endif
/* DOXYGEN */
typedef
enum
{
EMBB_THREAD_PRIORITY_IDLE
,
EMBB_THREAD_PRIORITY_LOWEST
,
EMBB_THREAD_PRIORITY_BELOW_NORMAL
,
EMBB_THREAD_PRIORITY_NORMAL
,
EMBB_THREAD_PRIORITY_ABOVE_NORMAL
,
EMBB_THREAD_PRIORITY_HIGHEST
,
EMBB_THREAD_PRIORITY_TIME_CRITICAL
}
embb_thread_priority_t
;
/**
* Thread start function pointer type.
*
...
...
@@ -180,6 +190,11 @@ int embb_thread_equal(
/**< [IN] Second thread (right-hand side of equality sign) */
);
int
embb_thread_set_priority
(
embb_thread_t
*
thread
,
embb_thread_priority_t
priority
);
#ifdef __cplusplus
}
/* Close extern "C" { */
#endif
...
...
base_c/src/thread.c
View file @
62c77d0a
...
...
@@ -164,6 +164,43 @@ int embb_thread_equal(const embb_thread_t* lhs, const embb_thread_t* rhs) {
return
0
;
}
int
embb_thread_set_priority
(
embb_thread_t
*
thread
,
embb_thread_priority_t
priority
)
{
int
internal_priority
;
switch
(
priority
)
{
case
EMBB_THREAD_PRIORITY_IDLE
:
internal_priority
=
THREAD_PRIORITY_IDLE
;
break
;
case
EMBB_THREAD_PRIORITY_LOWEST
:
internal_priority
=
THREAD_PRIORITY_LOWEST
;
break
;
case
EMBB_THREAD_PRIORITY_BELOW_NORMAL
:
internal_priority
=
THREAD_PRIORITY_BELOW_NORMAL
;
break
;
case
EMBB_THREAD_PRIORITY_ABOVE_NORMAL
:
internal_priority
=
THREAD_PRIORITY_ABOVE_NORMAL
;
break
;
case
EMBB_THREAD_PRIORITY_HIGHEST
:
internal_priority
=
THREAD_PRIORITY_HIGHEST
;
break
;
case
EMBB_THREAD_PRIORITY_TIME_CRITICAL
:
internal_priority
=
THREAD_PRIORITY_TIME_CRITICAL
;
break
;
case
EMBB_THREAD_PRIORITY_NORMAL
:
default:
internal_priority
=
THREAD_PRIORITY_NORMAL
;
break
;
}
BOOL
result
=
SetThreadPriority
(
thread
->
embb_internal_handle
,
internal_priority
);
if
(
result
!=
0
)
{
return
EMBB_SUCCESS
;
}
else
{
return
EMBB_ERROR
;
}
}
#endif
/* EMBB_PLATFORM_THREADING_WINTHREADS */
#ifdef EMBB_PLATFORM_THREADING_POSIXTHREADS
...
...
@@ -299,4 +336,12 @@ int embb_thread_equal(const embb_thread_t* lhs, const embb_thread_t* rhs) {
return
pthread_equal
(
lhs
->
embb_internal_handle
,
rhs
->
embb_internal_handle
);
}
int
embb_thread_set_priority
(
embb_thread_t
*
/*thread*/
,
embb_thread_priority_t
/*priority*/
)
{
// not implemented yet
return
EMBB_ERROR
;
}
#endif
/* EMBB_PLATFORM_THREADING_POSIXTHREADS */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment