Download Processes and Interprocess Communication: A Deep Dive into Linux Operating System and more Slides Software Engineering in PDF only on Docsity!
Chapter 3: Processes
Chapter 3: Processes
- (^) Process Concept
- (^) Process Scheduling
- (^) Operations on Processes
- (^) Interprocess Communication
- (^) Examples of IPC Systems
- (^) Communication in Client-Server Systems
Process Concept
- (^) An operating system executes a variety of programs:
- (^) Batch system – jobs
- (^) Time-shared systems – user programs or tasks
- (^) Textbook uses the terms job and process almost interchangeably
- (^) Process – a program in execution; process execution must progress in sequential fashion
- (^) Multiple parts
- (^) The program code, also called text section
- (^) Current activity including program counter , processor registers
- (^) Stack containing temporary data
- (^) Function parameters, return addresses, local variables
- (^) Data section containing global variables
- (^) Heap containing memory dynamically allocated during run time
- (^) Program is passive entity stored on disk ( executable file ), process is active
- (^) Program becomes process when executable file loaded into memory
- (^) Execution of program started via GUI mouse clicks, command line entry of its name, etc
- (^) One program can be several processes
- (^) Consider multiple users executing the same program
Process in Memory
Diagram of Process State
Process Control Block (PCB)
Information associated with each process
(also called task control block )
- (^) Process state – running, waiting, etc
- (^) Program counter – location of instruction
to next execute
- (^) CPU registers – contents of all process-
centric registers
- (^) CPU scheduling information- priorities,
scheduling queue pointers
- (^) Memory-management information –
memory allocated to the process
- (^) Accounting information – CPU used, clock
time elapsed since start, time limits
- (^) I/O status information – I/O devices
allocated to process, list of open files
Threads
- (^) So far, process has a single thread of execution
- (^) Consider having multiple program counters per process
- (^) Multiple locations can execute at once
- (^) Multiple threads of control -> threads
- (^) Must then have storage for thread details, multiple program
counters in PCB
Process Representation in Linux
- (^) Represented by the C structure task_struct pid t_pid; /* process identifier / long state; / state of the process / unsigned int time_slice / scheduling information */ struct task_struct parent; / this process’s parent / struct list_head children; / this process’s children */ struct files_struct files; / list of open files */ struct mm_struct mm; / address space of this process */
Ready Queue And Various I/O Device Queues
Representation of Process Scheduling
(^) Queueing diagram represents queues, resources, flows
Addition of Medium Term Scheduling
(^) Medium-term scheduler can be added if degree of multiple programming needs to decrease (^) Remove process from memory, store on disk, bring back in from disk to continue execution: swapping
Multitasking in Mobile Systems
- (^) Some systems / early systems allow only one process to run, others
suspended
- (^) Due to screen real estate, user interface limits iOS provides for a
- (^) Single foreground process- controlled via user interface
- (^) Multiple background processes– in memory, running, but not on the display, and with limits
- (^) Limits include single, short task, receiving notification of events, specific long- running tasks like audio playback
- (^) Android runs foreground and background, with fewer limits
- (^) Background process uses a service to perform tasks
- (^) Service can keep running even if background process is suspended
- (^) Service has no user interface, small memory use
Operations on Processes
- (^) System must provide mechanisms for process creation,
termination, and so on as detailed next
Process Creation
- (^) Parent process create children processes, which, in turn create
other processes, forming a tree of processes
- (^) Generally, process identified and managed via a process identifier
( pid )
- (^) Resource sharing options
- (^) Parent and children share all resources
- (^) Children share subset of parent’s resources
- (^) Parent and child share no resources
- (^) Execution options
- (^) Parent and children execute concurrently
- (^) Parent waits until children terminate