feat: better scheduling for fibo

This commit is contained in:
Alessandre Laguierce 2025-04-02 15:24:30 +02:00
parent 3475ce4e8f
commit 7f1aa05f3e
2 changed files with 7 additions and 2 deletions

View File

@ -109,7 +109,7 @@ ${check_targets}: check_%: ${build_dir}/%
$^ ${check_argv}
${bins_target}: ${build_dir}/%: ${objs} ${build_dir}/${tst_dir}/%.o
${CC} -o $@ $^ ${CFLAGS} ./lib/libmimalloc ${LDFLAGS}
${CC} -o $@ $^ ${CFLAGS} ${LDFLAGS}
${build_dir}/libthread.so: ${objs}
${CC} -o $@ -shared $^ ${CFLAGS} ${LDFLAGS}

View File

@ -17,7 +17,8 @@
#define IS_WAITING(entry) (entry->status & WAITING)
#define GET_LAST_WAITED_THREAD(entry) (entry->last_waited ? entry->last_waited->last_thread : NULL)
#define WAITED 0x8
#define MUTEX_WAITING 0xf0
#define YIELD (char) 0x20
#define MUTEX_WAITING (char) 0x10
#define IS_WAITED(entry) (entry->status & WAITED)
#define IS_MUTEX_WAITING(entry) (entry->status & MUTEX_WAITING)
@ -79,6 +80,10 @@ int thread_yield(void)
if (TAILQ_EMPTY(&head)) {
return 0;
}
if (!(running->status & YIELD)) {
running->status |= YIELD;
return 0;
}
/* Current strategy :
* if we have checked the number of threads then keep the running one