Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
PolyORB-HI-C
Commits
559fb158
Commit
559fb158
authored
Mar 10, 2017
by
yoogx
Browse files
* Test if selected core is supported on the target
For issue
#16
parent
1cc79646
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/po_hi_task.c
View file @
559fb158
...
...
@@ -36,6 +36,7 @@
#if defined (__CYGWIN__) || defined (__MINGW32__) || defined (RTEMS_POSIX) || defined (RTEMS_PURE)
#else
#include
<xlocale.h>
#include
<unistd.h>
#endif
#include
<pthread.h>
...
...
@@ -338,6 +339,26 @@ int __po_hi_initialize_tasking( )
return
(
__PO_HI_SUCCESS
);
}
/*
* For multi-core aware systems, this function returns the number of
* core available
*/
#if defined (POSIX) || defined (RTEMS_POSIX)
int
__po_hi_number_of_cpus
(
void
)
{
int
cores
=
1
;
#if defined (__linux__) || defined (__APPLE__)
cores
=
(
int
)
sysconf
(
_SC_NPROCESSORS_ONLN
);
#endif
return
cores
;
}
#endif
/*
* For each kind of system, we declare a generic function that
* create a thread. For POSIX-compliant systems, the function
...
...
@@ -370,6 +391,12 @@ pthread_t __po_hi_posix_create_thread (__po_hi_priority_t priority,
/* Thread affinity */
cpu_set_t
cpuset
;
if
(
core_id
>
__po_hi_number_of_cpus
()
)
{
__PO_HI_DEBUG_CRITICAL
(
"Invalid CPU core id
\n
"
);
return
((
pthread_t
)
__PO_HI_ERROR_PTHREAD_ATTR
);
}
CPU_ZERO
(
&
cpuset
);
CPU_SET
(
core_id
,
&
cpuset
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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