Processes
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
Process Concept (Cont.)
• 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
Process State
• As a process executes, it changes state
• new: The process is being created
• running: Instructions are being executed
• waiting: The process is waiting for some event to occur
• ready: The process is waiting to be assigned to a processor
• terminated: The process has finished execution
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
System Calls
• System calls are used to provide an interface between the operating
system and the user programs(processes).
• The set of system calls is vary from operating system to operating
system.
• A process( i.e. a program in execution) can run in two modes – user
mode and kernel mode (or operating system mode).
Types of System Calls
• Process control
• create process, terminate process
• end, abort
• load, execute
• get process attributes, set process attributes
• wait for time
• wait event, signal event
• allocate and free memory
• Dump memory if error
• Debugger for determining bugs, single step execution
• Locks for managing access to shared data between processes
Types of System Calls (Cont.)
• File management
• create file, delete file
• open, close file
• read, write, reposition
• get and set file attributes
• Device management
• request device, release device
• read, write, reposition
• get device attributes, set device attributes
• logically attach or detach devices
Types of System Calls (Cont.)
• Information maintenance
• get time or date, set time or date
• get system data, set system data
• get and set process, file, or device attributes
• Communications
• create, delete communication connection
• send, receive messages if message passing model to host name or process
name
• From client to server
• Shared-memory model create and gain access to memory regions
• transfer status information
• attach and detach remote devices
Types of System Calls (Cont.)
• Protection
• Control access to resources
• Get and set permissions
• Allow and deny user access
• User goals and System goals
• User goals – operating system should be convenient to use, easy to learn,
reliable, safe, and fast
• System goals – operating system should be easy to design, implement, and
maintain, as well as flexible, reliable, error-free, and efficient