feat: create a pool of threads when setuping main thread
This commit is contained in:
parent
da29a7eea4
commit
af7960b264
@ -343,6 +343,24 @@ void __attribute__((constructor)) setup_main_thread()
|
|||||||
{
|
{
|
||||||
TRACE("premain");
|
TRACE("premain");
|
||||||
// Create an entry for the main thread.
|
// Create an entry for the main thread.
|
||||||
|
|
||||||
|
struct context_entry_t *new_entry;
|
||||||
|
for (int i = 0; i < 1000; ++i) {
|
||||||
|
|
||||||
|
new_entry = malloc(sizeof(*new_entry));
|
||||||
|
memset(new_entry->stack, 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;
|
||||||
|
|
||||||
|
// Tell Valgrind that the memory area of the future stack is a stack
|
||||||
|
new_entry->valgrind_id = VALGRIND_STACK_REGISTER(
|
||||||
|
new_entry->context.uc_stack.ss_sp,
|
||||||
|
new_entry->context.uc_stack.ss_sp + new_entry->context.uc_stack.ss_size);
|
||||||
|
TAILQ_INSERT_TAIL(&context_to_freed, new_entry, link);
|
||||||
|
}
|
||||||
|
|
||||||
struct context_entry_t* main = malloc(sizeof(*main));
|
struct context_entry_t* main = malloc(sizeof(*main));
|
||||||
// memset(main, 0, sizeof(*main));
|
// memset(main, 0, sizeof(*main));
|
||||||
getcontext(&main->context);
|
getcontext(&main->context);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user