Aleksandar Ristovski(deleted)
|
|
Aleksandar Ristovski(deleted)
04/23/2015 1:45 PM
post113743
|
Please see the documentation for DCMD_PROC_THREADCTL and _NTO_TCTL_RUNMASK:
Something like:
...
unsigned long runmask = 0x1ul; // run on first cpu only.
procfs_threadctl tctl;
tctl.tid=<tid>;
tctl.cmd=_NTO_TCTL_RUNMASK;
tctl.data=(void*)runmask;
int rc = devctl(fd, DCMD_PROC_THREADCTL, &tctl, sizeof(tctl), NULL);
...
But since you are creating the thread you could do an easier trick with
ThreadCtl by providing a setup thread routine. E.g.
...
struct th_setup_data
{
void* (*start_routine)(void* );
unsigned long runmask;
void* realarg;
};
static void *
th_setup_routine(void *tsdp)
{
struct th_setup_data *tsp = tsdp;
if (ThreadCtl(_NTO_TCL_RUNMASK, (void*)tsp->runmask) == -1) {
/* Failed. Do something about it. */
abort();
}
return (tsp->start_routine)(tsp->realarg);
}
...
struct th_setup_data tsd = { your_thread_start_routine, 0x1ul, your_arg };
pthread_t th;
if (pthread_create(&th, &attr, th_setup_routine, &tsd) != EOK) {
abort();
}
/* If tsd is a stack variable, sync. ht_setup_routine with this thread */
...
(Note: snippet above is just for illustration, I did not compile it).
HTH,
Aleksandar
|
|
|