mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
use mwait to check the readyqueue for new arriving tasks
This commit is contained in:
parent
f1ed79144a
commit
068fbf2cb6
5 changed files with 34 additions and 13 deletions
|
@ -136,3 +136,18 @@ int create_default_frame(task_t* task, entry_point_t ep, void* arg, uint32_t cor
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wait_for_task(void)
|
||||
{
|
||||
if (!has_mwait()) {
|
||||
PAUSE;
|
||||
} else {
|
||||
void* queue = get_readyqueue();
|
||||
|
||||
if (has_clflush())
|
||||
clflush(queue);
|
||||
|
||||
monitor(queue, 0, 0);
|
||||
mwait(0xF /* = c0 */, 1 /* break on interrupt flag */);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,6 +187,17 @@ int wakeup_task(tid_t);
|
|||
*/
|
||||
int block_current_task(void);
|
||||
|
||||
/** @brief Block task until a new arrived
|
||||
*
|
||||
*/
|
||||
void wait_for_task(void);
|
||||
|
||||
/** @brief Get readyqueue of the current core
|
||||
*
|
||||
* @return
|
||||
* - address of the readyqueue
|
||||
*/
|
||||
void* get_readyqueue(void);
|
||||
|
||||
/** @brief Get a process control block
|
||||
*
|
||||
|
|
|
@ -95,8 +95,6 @@ extern int32_t possible_isles;
|
|||
extern uint32_t boot_processor;
|
||||
extern volatile int libc_sd;
|
||||
|
||||
uint32_t idle_poll = 1;
|
||||
|
||||
islelock_t* rcce_lock = NULL;
|
||||
rcce_mpb_t* rcce_mpb = NULL;
|
||||
|
||||
|
@ -307,10 +305,7 @@ int smp_main(void)
|
|||
|
||||
while(1) {
|
||||
check_workqueues();
|
||||
if (idle_poll)
|
||||
PAUSE;
|
||||
else
|
||||
HALT;
|
||||
wait_for_task();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -615,10 +610,7 @@ int hermit_main(void)
|
|||
|
||||
while(1) {
|
||||
check_workqueues();
|
||||
if (idle_poll)
|
||||
PAUSE;
|
||||
else
|
||||
HALT;
|
||||
wait_for_task();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -50,7 +50,6 @@ extern spinlock_irqsave_t stdio_lock;
|
|||
extern int32_t isle;
|
||||
extern int32_t possible_isles;
|
||||
extern volatile int libc_sd;
|
||||
extern uint32_t idle_poll;
|
||||
|
||||
tid_t sys_getpid(void)
|
||||
{
|
||||
|
@ -99,9 +98,7 @@ void NORETURN sys_exit(int arg)
|
|||
reschedule();
|
||||
|
||||
lwip_close(s);
|
||||
idle_poll = 0;
|
||||
} else {
|
||||
idle_poll = 0;
|
||||
spinlock_irqsave_unlock(&lwip_lock);
|
||||
}
|
||||
|
||||
|
|
|
@ -232,6 +232,12 @@ uint32_t get_highest_priority(void)
|
|||
}
|
||||
|
||||
|
||||
void* get_readyqueue(void)
|
||||
{
|
||||
return &readyqueues[CORE_ID];
|
||||
}
|
||||
|
||||
|
||||
int multitasking_init(void)
|
||||
{
|
||||
uint32_t core_id = CORE_ID;
|
||||
|
|
Loading…
Add table
Reference in a new issue