1
0
Fork 0
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:
Stefan Lankes 2016-11-06 19:26:19 +01:00
parent f1ed79144a
commit 068fbf2cb6
5 changed files with 34 additions and 13 deletions

View file

@ -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 */);
}
}

View file

@ -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
*

View file

@ -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;

View file

@ -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);
}

View file

@ -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;