Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
Loading...
Searching...
No Matches
srn_worker_t Struct Reference

The state one os thread uses to run fibers. More...

Collaboration diagram for srn_worker_t:
[legend]

Data Fields

srn_scheduler_tsched
srn_fiber_t loop
srn_fiber_tcurrent
srn_worker_id_t id
uint64_t spawned
 Count of fibers this worker has created so far.
atomic_intptr_t top
 Chase-Lev deque.
atomic_intptr_t bottom

Detailed Description

The state one os thread uses to run fibers.

The worker's loop (loop) represents the os thread itself and is the resumer for every fiber this worker runs. Each worker owns a lock free Chase-Lev work stealing deque. The owner pushes and pops the bottom end, while thieves take from the top end. So the common push and pop touch no lock, and only a steal contends.

Definition at line 230 of file scheduler.c.

Field Documentation

◆ bottom

atomic_intptr_t srn_worker_t::bottom

Definition at line 246 of file scheduler.c.

◆ current

srn_fiber_t* srn_worker_t::current

Definition at line 233 of file scheduler.c.

◆ id

srn_worker_id_t srn_worker_t::id

Definition at line 234 of file scheduler.c.

◆ loop

srn_fiber_t srn_worker_t::loop

Definition at line 232 of file scheduler.c.

◆ sched

srn_scheduler_t* srn_worker_t::sched

Definition at line 231 of file scheduler.c.

◆ spawned

uint64_t srn_worker_t::spawned

Count of fibers this worker has created so far.

Feeds the autogenerated fiber names, worker local so no synchronization is needed.

Definition at line 238 of file scheduler.c.

◆ top

atomic_intptr_t srn_worker_t::top

Chase-Lev deque.

top and bottom are signed and monotonically increasing (signed so the transient bottom - 1 on an empty deque does not wrap), and the live slot for an index is index & (SRN_FIBER_LOCAL_RING_CAP - 1). TODO(lxsameer): Make the ring capacity configurable via CLI args.

Definition at line 245 of file scheduler.c.


The documentation for this struct was generated from the following file: