revert: awful time on thor

This commit is contained in:
Alessandre Laguierce 2025-04-02 19:28:42 +02:00
parent f6b03da814
commit 589c6551f7
2 changed files with 5 additions and 12 deletions

View File

@ -17,8 +17,7 @@
#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 YIELD (char) 0x20
#define MUTEX_WAITING (char) 0x10
#define MUTEX_WAITING 0xf0
#define IS_WAITED(entry) (entry->status & WAITED)
#define IS_MUTEX_WAITING(entry) (entry->status & MUTEX_WAITING)
@ -48,6 +47,7 @@ struct context_entry {
struct mutex_fifo_entry_t* mutex_fifo_entry;
int valgrind_id;
char status;
char stack[STACK_SIZE];
};
struct last_thread_t {
@ -79,10 +79,6 @@ int thread_yield(void)
if (TAILQ_EMPTY(&head)) {
return 0;
}
if (!(running->status & YIELD) && !IS_FINISHED(running)) {
running->status |= YIELD;
return 0;
}
/* Current strategy :
* if we have checked the number of threads then keep the running one
@ -137,9 +133,9 @@ int thread_create(thread_t* newthread, void* (*func)(void*), void* funcarg)
} else {
TRACE("Allocating new entry");
new_entry = malloc(sizeof(*new_entry));
memset(new_entry->stack, 0, STACK_SIZE);
new_entry->context.uc_stack.ss_sp = malloc(STACK_SIZE);
memset(new_entry->context.uc_stack.ss_sp, 0, STACK_SIZE);
new_entry->context.uc_stack.ss_sp = new_entry->stack;
new_entry->context.uc_stack.ss_size = STACK_SIZE;
new_entry->context.uc_stack.ss_flags = 0;
@ -261,7 +257,6 @@ int thread_join(thread_t thread, void** retval)
DBG("ADDING (%p) TO FREED TAIL", entry);
TAILQ_INSERT_TAIL(&context_to_freed, entry, link);
} else {
free(entry->context.uc_stack.ss_sp);
free(entry);
}
@ -297,7 +292,6 @@ void clear_context(void)
TAILQ_REMOVE(&head, last, link);
free(last->mutex_fifo_entry);
if (WAS_ALLOCATED(last)) {
free(last->context.uc_stack.ss_sp);
VALGRIND_STACK_DEREGISTER(last->valgrind_id);
}
if (IS_WAITED(last)) {
@ -311,7 +305,6 @@ void clear_context(void)
free(last->mutex_fifo_entry);
TAILQ_REMOVE(&context_to_freed, last, link);
if (WAS_ALLOCATED(last)) {
free(last->context.uc_stack.ss_sp);
VALGRIND_STACK_DEREGISTER(last->valgrind_id);
}
free(last);