...
- For each process, the Arachne module in kernel maintains a dynamically-sized kernel thread pool for each core in the system
- The pool is initially empty and threads are created by needas needed.
- The new kernel threads are created using syscall `clone` with the starting function set to the Arachne main loop.
- We do not need a different clone call because there is already a flag for indicating the type of thread in the existing mechanisms.
- When the kernel decides to allocate a core to a process, it takes one kernel thread from the corresponding pool and put it in the run queue
- run queue is a per-cpu per-scheduling-class data structure
Q1: Can we have just one thread pool instead?
RELEASE A CORE VOLUNTARILY
...
- First, the kernel will ask nicely by leaving a message in the shared memory indicating that it wants N cores back.
- Arachne then decides which cores to give back to the kernel.
- If somehow an Arachne user thread does not yield in time to relinquish the core, the kernel will be forced to preempt the insubordinate thread T.
- Thread T will be downgraded to a SCHED_OTHER thread and scheduled by the CFS.
- Later when T finally gets back to the main loop, it will notice that it no longer binds to a core and then exit the main loop.
HANDLE BLOCKING SYSCALLS IN KERNEL
...
The scheduling policy used by a particular thread is indicated by the `policy` field in `task_struct`: http://lxr.free-electrons.com/source/include/linux/sched.h?v=4.7#L1495.
SAMPLE ARACHNE MAIN LOOP IMPLEMENTATION
...