I am a progmatic engineer and this is a practical book. It shouldbe fun, easy to read, and useful. ——Robert Love
I’ve dived into the book in recent two weeks, it’s surprising that how straight forward and funny the book is. Armed with knowledge of the design and implement of the kernel, some oracle featurne such as latching,enqueue suddently become clear to me.
Here comes some notes, I’ll definitely go through the book for second time, then the Part II will come:-)
1. About the Process status
TASK_RUNNING: This is the only possible state for a process executing in the user-space.
If The process is in user-space, it is now running on CPU or wait for CPU in run queue.
If the process need to proactive sleep or wait, it is done by system call, which is in kernel-space. For example, in oracle, when the server process wait for the enqueue TX, the waiting is done by semorphore operation, the system call semop.
sid@SID10G> create table t as select 1 n from dual;
sid@SID10G> update t set n = 2;
1 row updated.
--session 2 is blocked
sid@SID10G> update t set n = 3;
–if we trace the process of session 2 where is is blocked, we can found the process wait and timeout on the semop syscall every 3 seconds.
oracle ~ $sudo dtruss -p 48367
semop(0x40002, 0x7FFF5FBF6C80, 0x1) = -1 Err#4
2. Thread in Linux
To the Linux kernel, there is no concept of a thread. Linux implements all threads as standard process.
Thread is process, just share resource, such as the process address space, file descriptor.
3. Complete Fair Scheduling in 2.6 Kernel
When the CFS id deciding what process to run next, it picks the process with the smallest vruntime.
it’s surpprising to see that there is no fixed *timeslice* concept in the schedule algorithim, the CFS will make sure all the process share the same cpu resource, the one have least cpu time will be selected to run.
Start simple and grow in complexity as needed, Simplicity is key.
Picking the right value, like a successful relationship, is all about compromise