Operating Systems - PowerPoint PPT Presentation

1 / 65
About This Presentation
Title:

Operating Systems

Description:

... additional indirect load on other resources or incurring design modification ... Other software units can execute as though there were large main memory in ... – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 66
Provided by: shyhka
Category:

less

Transcript and Presenter's Notes

Title: Operating Systems


1
Operating Systems
  • Shyh-Kang Jeng
  • Department of Electrical Engineering/
  • Graduate Institute of Communication Engineering
  • National Taiwan University

2
Operating Systems
  • Interface between a user and the computer
    hardware
  • Provide an environment in which a user can
    execute programs
  • Goals
  • Make the computer system convenient to use
  • Use the computer hardware (resources) in an
    efficient manner

3
Batch Processing
Especially suitable for payroll processing
4
Interactive Processing
5
Real-Time Processing and Time-Sharing Systems
  • Real-time processing
  • Processing whose response time is restricted
  • Time-sharing systems
  • Shuffle jobs by dividing time into intervals
  • Multitasking for a one-user system
  • Efficient than the sequential way especially for
    jobs which must wait for peripheral devices

6
Multiprocessor Systems
  • Sharing information and resources among different
    machines
  • Networks
  • Coupled computer systems
  • Software controlling a network is as a
    network-worldwide operating system
  • Load balancing
  • Dynamically allocate tasks to various processes
    so that all processors are used efficiently
  • Scaling
  • Break tasks into a number of subtasks compatible
    with the number of processors available

7
Scalability
  • Capability of a system to adapt to increased
    service load
  • A scalable system reacts more gracefully to
    increased load than does a non-scalable one
  • A scalable system has the potential to grow
    without problems like generating additional
    indirect load on other resources or incurring
    design modification

8
Application and System Software
  • Application software
  • Performs tasks particular to the machines
    utilization
  • System software
  • Performs tasks common to computer system in
    general
  • OS utility software
  • Utility software
  • Collection of software units extending the
    capabilities of OS

9
Software Classification
10
Shells
11
Shells
  • Portion of an OS to define the interface between
    the OS and its users
  • Types of shells
  • Textual interface
  • e.g., Borne shell, C shell, Korn shell in Unix
    MS-DOS for Microsoft Windows
  • Graphical user interface
  • e.g., WinXP, Mac
  • Window manager

12
Kernels
  • Performs the very basic functions required by the
    computer installation
  • Main components
  • File manager
  • Device drivers
  • Memory manager
  • Scheduler and dispatcher

13
File Manager
14
File Systems
  • Directory or folder
  • Path C\animals\prehistoric\dinosaurs
  • Any access to a file by other software units is
    obtained at the discretion of the file manager
  • File descriptor
  • Information needed to find and manipulate the file

15
Device Drivers
16
Device Drivers
  • Software units that communicate with the
    controllers to carry out operations on the
    peripheral devices attached to the machine
  • Each device driver is uniquely designed for its
    particular type of device
  • Example Device driver for a printer contains
    software to read and decode status word as well
    as other handshaking details. Other software
    does not have to deal with those technicalities
    in order to print a file
  • A generic OS can be customized for particular
    peripheral devices by merely installing
    appropriate device drivers

17
Memory Manager
  • Charged with the tasks of coordinating the
    machines use of main memory
  • Such duties are extensive in multi-user or
    multitasking environments
  • Many programs and blocks of data reside in main
    memory concurrently
  • Must find places to fulfill memory requirements
    and keep track of memory areas no longer occupied

18
Virtual Memory
  • Illusion of additional memory space by rotating
    programs and data back and forth between main
    memory and mass storage
  • Useful when total main memory space required
    exceeds the space actually available in the
    machine
  • Divides the required space into units called
    pages and stores these pages in mass storage
  • Memory manager exchange pages required in memory
    for pages that are no longer required
  • Other software units can execute as though there
    were large main memory in the machine

19
PC Memory Manager
  • 4 GB addressable
  • space for 32-bit
  • addressing
  • Virtual memory
  • Page
  • Page fault

Mass Storage
20
Scheduler and Dispatcher
  • Scheduler
  • Determines which activities are to be considered
    for execution in a time-sharing system
  • Dispatcher
  • Controls the allocation of time slices to the
    scheduled activities

21
Boot Strapping (Booting)
  • Procedure performed by the machine each time it
    is turned on
  • Read-only memory (ROM) vs. Random access memory
    (RAM)
  • A small part of the main memory is constructed
    from ROM
  • Bootstrap program is stored in ROM and executed
    automatically when the machine is turned on

22
Bootstrap Program
  • Directs the CPU to transfer material from a
    predetermined location in mass storage into the
    volatile area of main memory
  • In most cases this material is the operating
    system
  • Once the operating system has been placed in main
    memory, the bootstrap program directs the CPU to
    execute a jump to that area of memory
  • At this point, the operating system takes over
    and begins controlling the machines behavior

23
Booting Process
24
Bootstrap in Personal Computers
  • Try to extract the operating system from a floppy
    disk first
  • If no such disks are found, the bootstrap will
    automatically try to extract the operating system
    from the machines hard disk
  • If floppy disk is inserted, and that disk does
    not contain a copy of the operating system, the
    bootstrap will pause with an error message to the
    machines operator

25
Concept of Process
  • Program
  • A static set of directions (passive entity)
  • Process
  • Program (application and utilities) in execution
    (active entity)
  • Needs resources to accomplish its task
  • Resources are given to the process when created
  • Can be executed in parallel
  • A single program can be associated with more than
    one process, each with its own data and rate of
    progress

26
Process Administration
  • Handled by scheduler and dispatcher within kernel
  • Scheduler
  • Maintains a process table
  • Dispatcher
  • Ensures the scheduled processes are actually
    executed
  • Time slice (or quantum) typically no more than
    50 milliseconds
  • Process switch

27
Process Table
  • Record of the process present in the computer
    system
  • Contains information of
  • Memory area assigned to the process
  • Priority of the process
  • Status of the process
  • Ready can continue
  • Waiting currently delayed until some external
    event occurs

28
Program and Processes
29
Processes in Windows
30
Time-Sharing Between Processes
31
Process Switch
  • The procedure of changing from one process to
    another
  • Occurs when an interrupt signal is generated at
    the end of the quantum
  • Process state of an executing process is saved
    and the process becomes idle
  • Interrupt is handled by interrupt handler
  • Process state of the process to be executed next
    is loaded
  • The new process starts running

32
Process State
  • A snapshot of the machine at that time
  • Defined by its current activity
  • Includes program counter, values in CPU registers
    and associated memory cells, etc.
  • Changes as a process executes

new
ready
running
halted
waiting
33
Interrupt Handler
  • Part of the dispatcher
  • Preempt the current process and transfer control
    back to the dispatcher
  • At this point, the dispatcher allows the
    scheduler to update the process table (e.g.,
    changing priorities)
  • The dispatcher then selects the process from the
    process table that has the highest priority among
    ready process
  • Restarts the timer circuit, and allow the
    selected process to begin its time slice

34
Terminating a Time Slice Early
  • For example, if a process executes an I/O
    request, the time slice of that process will be
    terminated
  • The scheduler will update the process table to
    reflect the processs waiting status
  • The dispatcher will assign a new quantum to a
    process that is ready
  • When the controller indicates that I/O request
    has been completed, the scheduler will reclassify
    the process as ready, and the process will again
    compete for a time slice

35
Mini Review
  • If each quantum in a time-sharing system is 50
    milliseconds and each context switch requires at
    most a microsecond, how many processes can the
    machine service in a single second?
  • If each process uses its complete quantum in the
    machine in last question, what fraction of the
    machines time is spent actually performing
    process? What would this fraction be if each
    process executes an I/O request after only a
    microsecond of its quantum?

36
Answer
  • If each process consumed its entire time slice,
    the machine could provide a complete quantum to
    almost 20 processes in one second. If processes
    did not consume their entire time slices, this
    value could be much higher, but then the time
    required to perform a context switch may become
    more significant

37
Answer (continue)
  • A total of 5000/5001 of the machines time would
    be spent actually performing processes. However,
    when a process requires an I/O activity, its time
    slice is terminated while the controller performs
    the request. Thus if each process made such a
    request after only one microsecond of its
    quantum, the efficiency of the machine would drop
    to ½.

38
Threads
Thread
Thread
Thread
Thread
CPU
Thread
Thread
Thread
Thread
Thread
Thread
Thread
Thread
J. Richter ??, ?????, Microsoft Windows
??????????, ??, 2001
39
Interprocess Communication
  • To coordinate activities of processes
  • For examples,
  • Scheduling a new process the scheduler must
    obtain memory space from the memory manager
  • Accessing a file in mass storage the process
    must first obtain information from the file
    manager

40
Client/Server Model forInterprocess Communication
41
Client/Server Model
  • Client makes requests
  • Server satisfies the requests made by clients
  • Simplifies inter-process communications
  • To gain uniformity among all types of
    communication taking place in the system, no
    matter they are at the same machine or different
    machines

42
Client-Server Communications
43
Communications between Software
44
Common Object Request Broker Architecture (CORBA)
45
Allocation of Resources
  • An important task of an operating system is the
    allocation of resources to the processes in the
    system
  • Resources machines peripheral devices as well
    as features within the machine
  • Access to files and disk space (file manager)
  • Memory space (memory manager)
  • Space in process table (scheduler)
  • Time slices (dispatcher)

46
Competition among Processes
  • Two alternatives
  • Disable interrupt in test and set
  • Test and set as a single instruction

47
Competition for Resources
  • Assume a process needs to print
  • Request the OS to give it access to the printers
    device driver
  • OS decide whether to grant the request, depending
    upon whether the printer is already being used by
    another process
  • If the printer is used by another process, the OS
    should deny the request and classify the process
    as waiting until the printer is ready
  • If two processes were given simultaneous access
    to printer, the results would be worthless to both

48
Using Flag to Control Access
  • OS must keep track of whether the printer has
    been allocated
  • Use a flag (a bit in memory) as set or clear to
    indicate that the printer is currently allocated
    or not
  • Testing and possibly setting the flag requires
    several machine instructions

49
A Possible Problem in the Flag Approach
Process 2
OS
Printer Device Driver
Process 1
Check flag
Request for printer
Grant access to printer
clear
Interrupt process
Check flag
Request for printer
clear
Grant access to printer
Set flag
Access printer
Resume process
Access printer
50
Two Solutions
  • Use the interrupt disable and interrupt enable
    instructions provided in most machine language
  • When OS starts the flag-testing routine, it
    disables the interrupt, and ends it by enabling
    the interrupt
  • Use the test-and-set instruction available in
    many machine language
  • Direct the CPU to retrieve the flag, note the
    value received, and set the flag, all within a
    machine instruction

51
Semaphores
  • Properly implemented flag

52
Critical Region and Mutual Exclusion
???, Visual C 6 ????????, ????, 1999.
53
Critical Region and Mutual Exclusion
  • Critical region A sequence of instructions that
    executed by only one process at a time
  • Mutual exclusion Requirement that only one
    process at a time to execute a critical region

54
Examples of Deadlock
  • One process has access to printer but is waiting
    for tape drive, while another process has access
    to tape drive but is waiting for printer
  • Scheduler has no space left in the process table
    and each process in the system must create an
    additional process before it can complete its task

55
Deadlock
  • A situation that two or more processes are
    blocked from processing because each is waiting
    for access the resources allocated to another
  • Degrade systems performance
  • Deadlock handling
  • Prevention
  • Avoidance
  • Detection and correction

56
Deadlock
57
Prerequisites of Deadlock
  • Competition for non-sharable resources
  • Resources are requested on a partial basis
  • Once a resource has been allocated, it can not be
    forcibly retrieved

58
Removing Deadlocks
  • Deadlock detection and correction schemes
  • Requiring each process to request all the
    resources at one time
  • Converting non-shareable resources into shareable
    ones

59
Examples of Removing Deadlock
  • If deadlock occur due to a full process table,
    the administrator merely uses his powers to
    remove (kill) some of the process
  • Spooling holding data for output at a later but
    more convenient time
  • Each time a process requires the printer, the OS
    grants the request. However, OS connects the
    process to a device that stores the information
    to be print on a disk
  • When the printer is available, OS transfers the
    data from the disk to printer

60
Mini Review
  • Suppose the following solutions have been
    proposed for removing the deadlock that occurs on
    a single-lane bridge when two cars meet.
    Identify which condition for deadlock is removed
    by each solution
  • Do not let a car onto the bridge until the bridge
    is empty
  • If cars met, make one of them back up
  • Add a second lane to the bridge

61
Answer
  • This guarantees that the non-shareable resource
    is not required and allocated on a partial basis
  • This means that the non-shareable resource can be
    forcibly retrieved
  • This makes the non-shareable resource shareable,
    which removes the competition

62
Another Competition Problem
  • A file manager could grant several processes
    access to the same file if the processes merely
    read data
  • Conflicts occur if more than one process tries to
    alter a file at the same time
  • File manager may allow only one process have
    write access at any given time
  • Other systems divide the file into pieces so that
    different processes can alter different parts of
    the file concurrently

63
Security from outside attacks
  • Most common protection require user name and
    password
  • Problem password stealing
  • Problem automated password guessers
  • Countermeasures
  • Always tell user when he/she last logged in
  • Report repeated bad guesses
  • Log the guesser into a captive account to spy on
    the guesser

64
Security from attacks from within
  • Operating system prevents illegal access to
    resources
  • Different memory for different processes
  • Privileged instructions only allowed in kernel
  • All file access passes through the kernel
  • Other devices can only be accessed through the
    kernel

65
Homework 3
  • 4, 7, 10, 11, 14, 18, 25, 29, 31, 37, 41
Write a Comment
User Comments (0)
About PowerShow.com