Friday, September 5, 2014
Linux Process Descriptor
Process and task are used interchangeably. The process descriptor is implemented in struct task_struct. The task list is a double linklist of task_struct.
Prior to 2.6 kernel, task_stuct is allocated at the end (max top) of kernel stack. This allow a quick location of the task_stuct using the stack register. Since 2.6, the task_struct is now allocated by the slab allocator dynamically in cache. A new struct thread_info sits at the top end of stack. The first element in thread_info points to task_struct. A register-impaired architecture is the only reason to create thread_info.
To look up the task_struct of the current task, kernel uses current macro. The implementation of current macro is hardware dependent. In x86, current is calculated by masking the lowest 13-bit of the esp stack pointer. In PowerPC, the current pointer is stored in a register.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment