mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
start new threads in round-robin manner over all cores
we assume OpenMP applications => number of threads is (normaly) equal to the number of cores => search next available core
This commit is contained in:
parent
73ee21674b
commit
b4e5bfef75
3 changed files with 19 additions and 5 deletions
|
@ -82,7 +82,7 @@ int multitasking_init(void);
|
|||
* - 0 on success
|
||||
* - -ENOMEM (-12) or -EINVAL (-22) on failure
|
||||
*/
|
||||
int clone_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t core_id);
|
||||
int clone_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio);
|
||||
|
||||
/** @brief Create a task with a specific entry point
|
||||
*
|
||||
|
|
|
@ -171,7 +171,7 @@ static int sys_sem_timedwait(sem_t *sem, unsigned int ms)
|
|||
|
||||
static int sys_clone(tid_t* id, void* ep, void* argv)
|
||||
{
|
||||
return clone_task(id, ep, argv, per_core(current_task)->prio, CORE_ID);
|
||||
return clone_task(id, ep, argv, per_core(current_task)->prio);
|
||||
}
|
||||
|
||||
static int default_handler(void)
|
||||
|
|
|
@ -262,12 +262,13 @@ void NORETURN abort(void) {
|
|||
do_exit(-1);
|
||||
}
|
||||
|
||||
int clone_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t core_id)
|
||||
int clone_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
uint32_t i;
|
||||
void* stack = NULL;
|
||||
task_t* curr_task;
|
||||
static uint32_t core_id = MAX_CORES;
|
||||
|
||||
if (BUILTIN_EXPECT(!ep, 0))
|
||||
return -EINVAL;
|
||||
|
@ -275,8 +276,6 @@ int clone_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t co
|
|||
return -EINVAL;
|
||||
if (BUILTIN_EXPECT(prio > MAX_PRIO, 0))
|
||||
return -EINVAL;
|
||||
if (BUILTIN_EXPECT(core_id >= MAX_CORES, 0))
|
||||
return -EINVAL;
|
||||
if (BUILTIN_EXPECT(!readyqueues[core_id].idle, 0))
|
||||
return -EINVAL;
|
||||
if (BUILTIN_EXPECT((size_t)ep < KERNEL_SPACE, 0))
|
||||
|
@ -290,6 +289,21 @@ int clone_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t co
|
|||
|
||||
spinlock_irqsave_lock(&table_lock);
|
||||
|
||||
if (core_id >= MAX_CORES)
|
||||
core_id = CORE_ID;
|
||||
|
||||
// we assume OpenMP applications
|
||||
// => number of threads is (normaly) equal to the number of cores
|
||||
// => search next available core
|
||||
for(i=0, core_id=(core_id+1)%MAX_CORES; i<MAX_CORES; i++, core_id=(core_id+1)%MAX_CORES)
|
||||
if (readyqueues[core_id].idle)
|
||||
break;
|
||||
|
||||
if ((core_id >= MAX_CORES) || !readyqueues[core_id].idle)
|
||||
core_id = CORE_ID;
|
||||
|
||||
kprintf("start new thread on core %d\n", core_id);
|
||||
|
||||
for(i=0; i<MAX_TASKS; i++) {
|
||||
if (task_table[i].status == TASK_INVALID) {
|
||||
task_table[i].id = i;
|
||||
|
|
Loading…
Add table
Reference in a new issue