mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
add helper function to run a task on a specific core
This commit is contained in:
parent
a916196c3d
commit
1a256ada95
2 changed files with 41 additions and 2 deletions
|
@ -68,7 +68,7 @@ size_t** scheduler(void);
|
|||
*/
|
||||
int multitasking_init(void);
|
||||
|
||||
/** @brief create a kernel-level task.
|
||||
/** @brief create a kernel-level task on the current core.
|
||||
*
|
||||
* @param id The value behind this pointer will be set to the new task's id
|
||||
* @param ep Pointer to the entry function for the new task
|
||||
|
@ -81,7 +81,21 @@ int multitasking_init(void);
|
|||
*/
|
||||
int create_kernel_task(tid_t* id, entry_point_t ep, void* args, uint8_t prio);
|
||||
|
||||
/** @brief Create a user level task.
|
||||
/** @brief create a kernel-level task.
|
||||
*
|
||||
* @param id The value behind this pointer will be set to the new task's id
|
||||
* @param ep Pointer to the entry function for the new task
|
||||
* @param args Arguments the task shall start with
|
||||
* @param prio Desired priority of the new kernel task
|
||||
* @param core_id Start the new task on the core with this id
|
||||
*
|
||||
* @return
|
||||
* - 0 on success
|
||||
* - -EINVAL (-22) on failure
|
||||
*/
|
||||
int create_kernel_task_on_core(tid_t* id, entry_point_t ep, void* args, uint8_t prio, uint32_t core_id);
|
||||
|
||||
/** @brief Create a user level task on the current core.
|
||||
*
|
||||
* @param id The value behind this pointer will be set to the new task's id
|
||||
* @param fname Filename of the executable to start the task with
|
||||
|
@ -93,6 +107,19 @@ int create_kernel_task(tid_t* id, entry_point_t ep, void* args, uint8_t prio);
|
|||
*/
|
||||
int create_user_task(tid_t* id, const char* fame, char** argv);
|
||||
|
||||
/** @brief Create a user level task.
|
||||
*
|
||||
* @param id The value behind this pointer will be set to the new task's id
|
||||
* @param fname Filename of the executable to start the task with
|
||||
* @param argv Pointer to arguments array
|
||||
* @param core_id Start the new task on the core with this id
|
||||
*
|
||||
* @return
|
||||
* - 0 on success
|
||||
* - -EINVAL (-22) or -ENOMEM (-12)on failure
|
||||
*/
|
||||
int create_user_task_on_core(tid_t* id, const char* fame, char** argv, uint32_t core_id);
|
||||
|
||||
/** @brief Create a task with a specific entry point
|
||||
*
|
||||
* @todo Don't acquire table_lock for the whole task creation.
|
||||
|
|
|
@ -211,6 +211,10 @@ int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t c
|
|||
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;
|
||||
|
||||
spinlock_irqsave_lock(&table_lock);
|
||||
|
||||
|
@ -267,6 +271,14 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int create_kernel_task_on_core(tid_t* id, entry_point_t ep, void* args, uint8_t prio, uint32_t core_id)
|
||||
{
|
||||
if (prio > MAX_PRIO)
|
||||
prio = NORMAL_PRIO;
|
||||
|
||||
return create_task(id, ep, args, prio, core_id);
|
||||
}
|
||||
|
||||
int create_kernel_task(tid_t* id, entry_point_t ep, void* args, uint8_t prio)
|
||||
{
|
||||
if (prio > MAX_PRIO)
|
||||
|
|
Loading…
Add table
Reference in a new issue