Course Overview Principles of Operating Systems - PowerPoint PPT Presentation

About This Presentation
Title:

Course Overview Principles of Operating Systems

Description:

Interprocess Communication. Important Concepts and Terms. Chapter Summary. Processes 3 ... process management, main memory, I/O devices, interprocess communication ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 59
Provided by: franzjk
Category:

less

Transcript and Presenter's Notes

Title: Course Overview Principles of Operating Systems


1
Course OverviewPrinciples of Operating Systems
  • Introduction
  • Computer System Structures
  • Operating System Structures
  • Processes
  • Process Synchronization
  • Deadlocks
  • CPU Scheduling
  • Memory Management
  • Virtual Memory
  • File Management
  • Security
  • Networking
  • Distributed Systems
  • Case Studies
  • Conclusions

2
Chapter Overview Processes
  • Motivation
  • Objectives
  • Processes and Programs
  • Process States
  • Operations on Processes
  • Operating System Control Structures
  • Process Control Block
  • Processes and Threads
  • Process Scheduling
  • Cooperating Processes
  • Interprocess Communication
  • Important Concepts and Terms
  • Chapter Summary

3
Motivation
  • applications can only run through the use of
    processes
  • processes are the fundamental unit of operation
    in an operating system
  • most components of the operating systems provide
    services for the execution of processes
  • processes require resources for their execution

4
Objectives
  • understand the use of processes for running
    programs
  • know the requirements and mechanisms for the
    execution of processes
  • understand the principles of cooperation between
    processes
  • acquire the terminology related to processes and
    their execution

5
Processes and Programs
  • both terms are used to describe the activities
    performed by a computer
  • program refers to the instructions as specified
    by the programmer
  • process refers to the activities performed by the
    computer as the instructions of a program are
    executed

6
Terminology
  • program
  • application
  • job
  • task
  • process
  • thread

7
Program
  • set of instructions specifying the activities
    necessary to accomplish a task
  • frequently used in a broad sense
  • static usually doesnt change unless modified by
    the programmer

8
Application
  • program used for a specific task
  • often used for programs available to the user, in
    contrast to programs used internally by the OS

9
Job
  • used to describe the unit of work in a batch
    system
  • frequently used synonymously to process

10
Task
  • unit of work from the users perspective in a
    time-sharing or multitasking system
  • often corresponds to an application program
  • may comprise several processes

11
Process
  • program in execution
  • unit of work from the OS perspective, in
    particular with respect to resource ownership
  • dynamic changes its state over time (during
    execution)
  • may consist of several threads

12
Thread
  • smallest dispatchable unit in the OS
  • several threads are usually grouped into a
    process, and can cooperate on a task
  • sometimes also called lightweight processes

13
Execution of Programs
  • multiprogramming
  • multiprocessing
  • multitasking
  • multithreading

14
Example Processes
  • consider three processes
  • process A executes 100 instructions, reads two
    blocks from hard disk, and executes another 100
    instructions
  • process B reads one block from hard disk,
    executes 100 instructions, and writes one block
    to disk
  • process C executes 1000 instructions, and writes
    two blocks to disk
  • timing
  • 10 ns per CPU instruction (100 MHertz clock
    frequency)
  • 10 ms average transfer time per block between
    hard disk and memory

15
Example Single-Programming
1,000 ns
A
B
C
10,000 ns
1,000 ns
1,000 ns
1,000 ns
I/O
I/O
I/O
I/O
20 ,000 ,000 ns
10 ,000 ,000 ns
10 ,000 ,000 ns
20 ,000 ,000 ns
  • overall execution time for single-programming20,0
    02,000 20,001,000 20,010,000 ns 60,013,000
    ns
  • CPU is idle for 60,000,000 ns

16
Multiprogramming
  • several programs are simultaneously under
    execution
  • they are between start and finish
  • simultaneously refers to a human time-scale
    (seconds)
  • at the CPU time scale, only one process is
    handled by the CPU (single processor systems)
  • creates logical parallelism
  • mainly used in batch systems to increase CPU
    utilization

17
Example Multiprogramming
1,000 ns
1,000 ns
A
  • logical parallelism all three programs are run
    simultaneously
  • problem only one CPU available

B
C
18
Example Multiprogramming
1,000 ns
1,000 ns
Attention Dimensions not to scale
10,000 ns
1,000 ns
1,000 ns
1,000 ns
I/O A
20 ,000 ,000 ns
10 ,000 ,000 ns
10 ,000 ,000 ns
20 ,000 ,000 ns
  • solution
  • multiplexing of the CPU by switching between
    processes
  • I/O operations concurrently with CPU operations
  • problem
  • more complex
  • requires process management

19
Multiprocessing
  • several processes run simultaneously on different
    CPUs
  • creates physical parallelism
  • advantages
  • short overall execution time
  • problems
  • CPUs might have to sharememory, I/O devices
  • low CPU utilization
  • communication between processes
  • process allocation and load balancing

20
Example Multiprocessing
1,000 ns
1,000 ns
  • physical parallelism all three programs are run
    simultaneously on three different CPUs

CPU 1
CPU 2
CPU 3
21
Multitasking
  • conceptually similar to multiprogramming better
    CPU utilization by switching between processes
  • more frequent switching so that users can
    interact with the program
  • necessary for time-sharing system

22
Multithreading
  • within one single process, multiple threads of
    execution are used
  • independent activities within one program or
    application can be performed in parallel
  • either on different CPUs, or via switching
    between threads
  • decreases the overhead of switching between
    processes

23
Process States
  • over their existence, processes can be in
    different states
  • newly created
  • ready to run on the CPU
  • running on the CPU
  • blocked because it is waiting for an event or an
    I/O operation
  • terminated

24
Process State Diagram
new
terminated
admission
release
dispatch
ready
running
time-out
I/O or event wait
I/O or event completion
blocked
25
Operations on Processes
  • process creation
  • new batch job, user login, OS service, child
    process
  • process termination
  • normal completion, time limit exceeded, resources
    unavailable, protection error, calculation error,
    invalid instruction, OS intervention, parent
    termination, parent request
  • context switch
  • execution of one process is stopped, and another
    process continues
  • change of process state
  • implicit via context switch, explicit by the OS

26
Operating System Control Structures
  • used to maintain information about important
    entities and activities in the computer system
  • management of processes and resources
  • information about the status of processes and
    devices
  • usually stored in tables, possibly with pointers
    to further information
  • cross-references must exist between different
    tables
  • the OS must know the basic configuration of the
    computer system

27
OS Control Structures
Process Image
Process Image
adapted from Stallings 98
28
Memory Tables
  • used to keep track of memory usage
  • allocation of main memory to processes
  • OS and user processes
  • allocation of secondary memory to processes
  • swap space or virtual memory
  • protection attributes of memory segments
  • access permissions

29
I/O Tables
  • used for the management of I/O devices
  • allocation of devices to processes
  • status of devices
  • available, allocated to a process
  • I/O operation in progress
  • memory segment involved in the I/O operation
  • in some operating systems, I/O devices are
    integrated into the file system

30
File Tables
  • used for the management of files and directories
  • access information for files
  • name, path
  • location on secondary memory
  • file status information
  • open, closed
  • processes using the file

31
Process Tables
  • used for the management of processes
  • location of the process
  • main memory, secondary storage
  • process attributes
  • process identification (pid)
  • unique number, often used as index into the
    process table
  • parent process, affiliated user, children

32
Process Image
  • user program
  • program to be executed
  • user data
  • program data, user stack, modifiable parts of the
    program
  • system stack
  • parameters, procedure call and return addresses
  • at least one per process
  • process control block
  • essential process data needed by the OS

33
Process Control Block
  • process identification
  • processor state information
  • process control information

34
Process Identification
  • process id, parent process, user id
  • used by the operating system for all activities
    involving processes
  • process management, main memory, I/O devices,
    interprocess communication
  • cross-reference to between process and other OS
    tables

35
Processor State Information
  • user registers
  • registers available to the user program
  • system registers
  • used for control and status information
  • program counter, condition codes (e.g. division
    by zero, overflow), status register (interrupt
    enabled, system/user mode)
  • stack pointers
  • points to the top of system stacks
  • these stacks contain parameters, procedure call
    and return addresses, and execution-related data

36
Process Control Information
  • scheduling and state information
  • process state, priority, time in ready queue,
    etc.
  • process relations
  • links to other processes (waiting queues,
    parent/child)interprocess communications
  • flags, signals, messages, shared memory
  • process privileges
  • memory access, instruction execution, resources
  • memory management
  • pointers to memory segments used by the process
  • resources
  • ownership and utilization of resources

37
Processes and Address Spaces
Process 1
Process 2
Process n
Process Identification
Process Identification
Process Identification
Process Control Block
Process State Information
Process State Information
Process State Information
Process Control Information
Process Control Information
Process Control Information
System Stack
System Stack
System Stack
User Stack
User Stack
User Stack
User Address Space
User Address Space
User Address Space
Shared Address Space
Shared Address Space
adapted from Stallings 98
38
Processes in Memory
  • several processes need to be accomodated
  • OS has its own memory section
  • simplified view
  • larger number of processes
  • processes do not occupy one single section in
    memory, but several smaller ones (non-contiguous
    allocation)
  • not the whole process image is always present in
    memory (virtual memory)

39
Process Scheduling
  • objective efficient allocation of CPU processing
    time to processes
  • in uniprocessor systems multiplexing of the CPU
    between processes
  • in multiprocessor systems allocation of
    processes to CPUs, load balancing across CPUs,
    multiplexing if there are more processes than
    processors
  • very important in multiprogramming and
    multitasking
  • maximization of CPU utilization
  • interaction between programs and users

40
Schedulers
  • job scheduler
  • long-term scheduling
  • medium-term scheduler
  • not used in all systems
  • CPU scheduler
  • short-term scheduling

41
Job Scheduler
  • manages processes that cant be executed
    immediately
  • not enough memory available
  • CPU load too high
  • processes waiting for I/O are kept separately
  • controls the degree of multiprogramming
  • number of processes in main memory
  • is not invoked too frequently
  • mainly when processes enter or leave the system

42
Medium-Term Scheduler
  • processes are temporarily moved out of main
    memory to secondary storage (swapping)
  • memory space restrictions
  • to improve the process mix (balance between
    CPU-intensive and I/O-intensive processes)
  • determines which processes to swap out and in

43
CPU scheduler
  • manages processes in the ready queue
  • processes have all the resources they need,
    except for CPU time
  • is invoked very frequently
  • a process requests an I/O operation
  • time slice of a process is over
  • interrupt or trap
  • OS intervention
  • must be very fast to reduce overhead

44
Scheduling Queues
  • first-in, first-out (FIFO) data structures used
    to administer the scheduling of processes
  • types of queues
  • job queue newly created processes not yet ready
    for execution
  • ready queue processes in main memory and ready
    for execution
  • device queue processes waiting for a particular
    device
  • event queue processes waiting for an event
  • queuing diagrams display the interdependencies
  • can be derived from the process state diagram

45
Two-State Process Model
Queuing Diagram
release
dispatch
admission
CPU
pause
adapted from Stallings 98
46
Five-State Process Model
47
Queuing Diagram Five-State
admission
release
forward
dispatch
CPU
Ready Queue
time-out
I/O or event wait
I/O or event completion
. . .
48
Context Switch
  • the execution of one process on the CPU is
    halted, and the CPU continues with another
  • information about the old process must be saved
  • saved information about the new process must be
    restored
  • highly dependent on hardware support
  • multiple sets of registers
  • special instructions, e.g. to load and store
    registers
  • context switching time is pure overhead
  • no productive work is done
  • should be kept as low as possible

49
Threads
  • reduce the overhead of context switching
  • only essential information about individual
    threads is saved for a thread switch
  • program counter, register set, stack
  • other information is shared by a group of threads
    within a process or task
  • code section, data section, resources
  • enable asynchronous and distributed processing
  • support modular programs
  • also sometimes referred to as lightweight
    processes

50
Types of Threads
  • user-level threads
  • managed by the user process instead of the OS
  • uses user-level libraries instead of system calls
  • often more efficient since the OS is not involved
  • can be difficult to program
  • kernel-level threads
  • scheduled by the OS
  • threads may be distributed over several processors

51
Multithreaded Process Model
Process
Process Control Block
adapted from Stallings 98
52
Cooperating Processes
  • processes existing simultaneously may be
    independent or cooperating processes
  • independent not affected by the execution of
    other processes in the system
  • processes are not completely independent since
    they have to share resources
  • cooperating influences the execution of other
    processes
  • information sharing
  • computation speedup
  • modularity

53
Example Producer-Consumer
  • a producer process produces data that is consumed
    by a consumer process
  • a buffer is used to allow producer and consumer
    processes to run concurrently
  • unbounded buffer unlimited size
  • bounded buffer limited size
  • explicitly coded (shared memory) or provided by
    the OS (interprocess communication)
  • shared data are accessed through regular memory
    read and write operations

54
Interprocess Communication
  • mechanisms for processes to communicate and
    synchronize their activities
  • does not rely on shared variables or shared
    memory
  • communication links must be established between
    processes
  • basic operations
  • send(message)
  • receive(message)

55
Direct Communication
  • processes must explicitly name the recipient or
    sender of the messages
  • send(receiver, message)
  • receive(sender, message)
  • processes must know each others identity
  • properties of direct links
  • links are established automatically by the OS
  • one link between a pair of processes
  • a link is associated with exactly two processes

56
Indirect Communication
  • messages are sent to and received from mailboxes
  • send(mailbox_1, message)
  • receive(mailbox_1 , message)
  • processes can communicate only if they share a
    mailbox
  • properties of direct links
  • links are established only if there is a common
    mailbox
  • mailboxes are created by the OS
  • there may be several links between a pair of
    processes
  • a mailbox may be associated with several processes

57
Important Concepts and Terms
  • address space
  • CPU scheduler
  • computer system
  • context switch
  • graphical user interface
  • hardware
  • interprocess communication
  • job
  • kernel-level thread
  • lightweight process
  • link
  • mailbox
  • message
  • message passing
  • multiprocessing
  • multiprogramming
  • multitasking
  • multithreading
  • port
  • process
  • register
  • resources, services
  • scheduling
  • shared memory
  • stack
  • task
  • thread
  • user-level thread

58
Chapter Summary Processes
  • a process is a program in execution
  • it is the dynamic entity associated with a static
    program
  • a process requires resources
  • CPU time, main memory, I/O devices
  • a process can be in one of several states
  • new, ready, running, blocked, terminated
  • process control block contains important
    information
  • processes are scheduled for execution
  • short, medium, long term scheduling
  • processes can run concurrently
  • independent or cooperating
  • multiplexing in a single-processor system
Write a Comment
User Comments (0)
About PowerShow.com