Download presentation
Presentation is loading. Please wait.
Published byMeryl Henderson Modified over 8 years ago
1
Processes David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO 63143 1
2
Processes in Linux Fundamental process abstraction: – Original: Each process behaves as though it has total control over the system – Modern: Threads still execute as though they monopolize the system, but the process abstraction also facilitates multi-threading, signals, and inter- process communication CSE 522S – Advanced Operating Systems2 More features: – Scheduling – Virtual Memory – Process accounting – Signals – Process groups – Synchronization – Multi-threading – Shared memory – Sockets – etc.
3
A process is an execution stack together with data that describes the process state. (also describes threads) Two stacks: – Kernel mode – User mode Data: – thread_info : small, efficient – task_struct : large, statically allocated by slab allocator, points to other data structs What is a Process, Really? CSE 522S – Advanced Operating Systems3 Kernel side:.bss User Stack.data.text User side: thread_info Kernel stack task_struct
4
Creating a New Process: fork() and clone() 1.Duplicate existing process 2.Initialize per-PID data – PID, real_parent, statistics 3.If new process: – Copies file handles, signal handlers, process address space, etc. – Resources shared via page-level lazy copy-on-write* 4.If new thread: – Shares pointers to above resources CSE 522S – Advanced Operating Systems4 thread_info Kernel stack task_struct ptr* 0x1 ptr* 0x2 ptr* 0x3 thread_info Kernel stack task_struct ptr* 0x1 ptr* 0x2 ptr* 0x3 *E.g. Every process in the system shares the same “copy” of the C library
5
Process States Alive states: TASK_RUNNING : running or runnable TASK_INTERRUPTIBLE : blocked on wait queue TASK_UNINTERRUPTIBLE : short duration blocking, can’t receive signals __TASK_TRACED : being traced with syscall ptrace __TASK_STOPPED : cannot execute ( SIGSTOP, debugger) Exit states: EXIT_ZOMBIE : exited but has not been waited for (kernel structures still exit) EXIT_DEAD : exited and has been waited for CSE 522S – Advanced Operating Systems5
6
Handling Processes in Linux Linux uses many containers to ensure efficient access to processes: – Linked list of all processes – Lists of child processes – PID hash table – Processor run queues – Blocking I/O wait queues Helper functions: for_each_process() list_for_each(list, task->children) CSE 522S – Advanced Operating Systems6 task_struct ptr* 0x1 ptr* 0x2 ptr* 0x3 task_struct ptr* 0x1 ptr* 0x2 ptr* 0x3 task_struct ptr* 0x1 ptr* 0x2 ptr* 0x3 task_struct ptr* 0x1 ptr* 0x2 ptr* 0x3 task_struct ptr* 0x1 ptr* 0x2 ptr* 0x3 task_struct ptr* 0x1 ptr* 0x2 ptr* 0x3
7
One Size Fits All Processes, threads, and kernel threads are all implemented with the same data structures ( thread_info and task_struct ) and functions. C has limited classes / polymorphism Logic and code for handling all runnable objects is the same Threads are like user processes but they share their parent’s address space. Kernel threads don’t have a user-side address space (i.e. mm_struct pointer is NULL ) and not all data values are used. CSE 522S – Advanced Operating Systems7
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.