ysbaddaden / execution_context

10 stars 2 forks source link

MT: thread imediately parks itself #28

Closed ysbaddaden closed 1 day ago

ysbaddaden commented 4 months ago

When a thread is started (after enqueueing a fiber) it immediately parks itself. We need a follow-up enqueue to wake it and then it starts stealing. For example starting a basic MT program:

sched.enqueue 43852663525099 thread=0x7f0aeba68740:DEFAULT-0 fiber=0x7f0aeba3df00:main fiber=0x7f0aeba3dd80:Signal Loop
sched.started 43852663659874 thread=0x7f0ae71f2700:DEFAULT-1 fiber=0x7f0aeba3dc00:DEFAULT-1:loop
sched.parking 43852663698976 thread=0x7f0ae71f2700:DEFAULT-1 fiber=0x7f0aeba3dc00:DEFAULT-1:loop
sched.enqueue 43852664205347 thread=0x7f0aeba68740:DEFAULT-0 fiber=0x7f0aeba3df00:main fiber=0x7f0aeba3db40:?
sched.wakeup 43852664236266 thread=0x7f0ae71f2700:DEFAULT-1 fiber=0x7f0aeba3dc00:DEFAULT-1:loop
sched.stolen 43852664268074 thread=0x7f0ae71f2700:DEFAULT-1 fiber=0x7f0aeba3dc00:DEFAULT-1:loop from=DEFAULT-0 size=0 fiber=0x7f0aeba3dd80:Signal Loop

The correct behavior would be to start the loop (check queues, try stealing, run the eventloop).

ysbaddaden commented 4 months ago

This only happens for the first additional thread we start (DEFAULT-1). It doesn't seem to happen for the next ones.