SlideShare ist ein Scribd-Unternehmen logo
1 von 79
Downloaden Sie, um offline zu lesen
MODULE 5



OPERATING SYSTEM
  Intermediate Level

 © Cutajar & Cutajar 2009
WHAT IS AN OPERATING SYSTEM



 An OPERATING SYSTEM (OS) is set of programs that
  manage all the hardware resources of a computer system,
  thus isolating the user from the complexities of direct use
  of the computer hardware.
 The operating system manages resources such as:
      input (keyboard, mouse, ),
      processing (CPU, … ),
      storage (main memory, hard discs, floppy discs, … )
      output ( monitor, printer, … ).
 It controls the way in which these resources are put to
  work.

                              Operating Systems              2
ROLE OF THE OPERATING SYSTEM




       User Interface




                                                 Hardware

                  User


OS Function Call Interface



                             Operating Systems              3
COMPUTER SYSTEM HIERARCHY


 The computer system hierarchy :

        User 1     User 2                             User n



           Compiler          database           word 
                             System             processor


                 System and application programs
                       Operating System
                      Computer Hardware

                            Operating Systems                   4
LOADING AN OPERATING SYSTEM


 The operating system is usually held on disk and has to be loaded into
  main memory once the computer is switched on before any other
  program can be run. Exception: In very compact systems, the OS may
  be held in ROM.
 The process of loading the operating system is called BOOTING the
  system.
 The BOOTSTRAP LOADER is an initial small program that executes
  itself once the system is powered on. This loader is held in ROM. It tells
  the computer where to look for the operating system and gives
  instructions to load at least part of it into memory.
 Once part of the OS has been loaded, more instructions can be executed
  to load the rest of the OS kernel (nucleus).
 The operating system then waits for some event to occur.


                               Operating Systems                        5
OBJECTIVES OF AN OPERATING SYSTEM


1. To make it possible for the resources of the computer to be
   used efficiently.
      Efficient resource utilisation is made especially difficult by the fact that
       some devices of a computer work much more quickly than others. Part of
       the task of the operating system is to ensure that fast devices such as
       processors, are not held up by slower peripheral devices. Thus the
       operating system is responsible for allocating and controlling use of all
       resources of a computer system.


2. To conceal the difficulties of dealing directly with the
   hardware of the computer.
      To simplify the use of the hardware of a computer, the OS creates a
       VIRTUAL MACHINE i.e. it takes care of the hardware difficulties presented
       by the different component devices of the computer system and provides
       the user with a simplified computer environment. Thus a computer user
       need only know about (and how to operate) the „virtual machine‟.
                                  Operating Systems                               6
DESIRABLE FEATURES OF OPERATING SYSTEMS


 Efficiency
    An OS must carry out its tasks promptly. Time spent on operating system
     functions is productive time wasted.
 Reliability
    Failure in an OS can render the host computer useless. An OS program
     should do what it has to do correctly. Ideally the OS should be error free
     and able to handle all contingencies - robustness.
 Maintainability
    Clearly written, well-structured (operating system) programs are essential
     for any later modifications. This is a very complex set of programs to
     develop; it is costly to produce (hence well-structuring and modularity
     encourage the reusability of code). Also remember that maintenance is the
     most costly part of any software existence cycle, hence having features
     which enhance maintainability help keep maintenance costs down.
 Small Size
    Space used to hold the OS whether in main memory or on backing store is
     wasted as far as productive computing is concerned.

                                 Operating Systems                                7
TYPES OF OPERATING SYSTEMS



 Operational mode is the form of operational organisation
  which determines the way in which the computer system is
  being used. This is determined by the operating system
  which is currently controlling the computer.
      Batch
      Online
      Multiprogramming (multitasking)
      Time-sharing (multi-access)
      Single-user
      Real-time
        o Hard real-time (process control)
        o Soft real-time (transaction processing)


                              Operating Systems         8
BATCH


 A number of programs are batched together and run as a group.
  Although the programs are run one at a time, input and output from
  various programs can overlap to some extent.
 Programs are usually queued up for batch processing and the
  operating system starts the next program in the queue as soon as
  sufficient computing resources are available for it. Some application
  area examples are payroll, processing of utility bills and master file
  updating process.
 The main characteristic of batch processing is the lack of interaction
  between the user and the job while the job is executing.
 Note that the above set up with the interleaving of batch jobs is
  better known as multiprogrammed batched system as against
  the simpler batch type where jobs are run one after the other.
  Multiprogrammed batch systems were facilitated by technological
  development. This set-up ensures better utilisation of the resources,
  the CPU in particular.
                             Operating Systems                         9
MULTIPROGRAMMING (MULTITASKING)


 At any one time, a number of programs
  are on the computer at various stages of
  completion. (Remember multi-programmed
  batch systems!).                          UNI   CPU idle
 Resources are allocated to programs
  according to the requirements of the
  programs and in order to maximise the
  usage of the resources of the computer.
 Having multiple jobs running concurrently
  on the same system implies more
  demanding operating system functions MULTI
  such as process scheduling, memory
  management and system security and
  protection.
 It also implies better utilisation of              CPU idle
  computer resources.
                                                                time
                           Operating Systems                     10
TIME-SHARING (MULTI-ACCESS)



 Time-sharing systems are a logical extension of multiprogramming
  systems. The operating system allows many users to use the
  computer at apparently the same time.
 Each job on the computer is given a quantum of processing time. The
  CPU switches from one job to another so quickly that each user is
  given the impression that s/he has her own computer, whereas
  actually one computer is being shared by several users.
 Time-sharing systems make possible the interactive use of multi-
  programmed computer systems. In this environment, the user gives
  instructions to the computer and immediately receives a response.
 Most operating systems provide both batch processing and time-
  sharing (although their basic design is either one or the other).



                            Operating Systems                     11
REAL-TIME SYSTEM



 A real-time system is used when there are rigid time requirements on
  the operation of a processor or the flow of data such as systems that
  control scientific experiments, medical imaging systems, industrial
  control systems, some display systems, home-appliance controllers,
  weapon systems.
 They can be classified in:
    Hard real-time (Real-time process control)
    Soft real-time (Real-time transaction processing)
                                                   BOOM!
     HARD

     SOFT
                                        deadline

                                                            time
                               Operating Systems                     12
REAL-TIME PROCESS CONTROL


 Real-time process control systems require that all delays are
  bounded, from the retrieval of stored data to the time that it takes the
  operating system to finish any request made of it.
 Such time constraints dictate the facilities that are available in hard
  real-time systems - secondary storage is either missing or very limited,
  virtual memory is non-existent, advanced OS features separating user
  from hardware are absent.

 Hard real-time systems cannot
  be mixed with the operation of
  time-sharing systems (and any
  general purpose operating
  system) because of conflicting
  features.


                              Operating Systems                        13
REAL-TIME ONLINE TRANSACTION PROCESSING


 Online Transaction Processing (OLTP) systems are
  less restrictive. A critical real-time task gets priority over
  other tasks and retains that priority until it completes. This
  type of real-time system may be mixed with other types of
  systems. (Application areas include interactive database
  applications, multimedia presentations, virtual reality, )




                           Operating Systems                   14
PARALLEL (MULTIPROCESSOR) SYSTEM


 Computer systems having more than one processor enjoy increased
  throughput (more work is done in a shorter period of time), increased
  reliability (failure of one processor will not halt the system - the
  ability to continue providing service proportional to the level of
  surviving hardware is called graceful degradation – systems designed
  for graceful degradation are called fault tolerant)


 Processors share the computer bus,
  the clock, memory and peripheral
  devices and are referred to as
  tightly coupled systems.




                              Operating Systems                      15
DISTRIBUTED SYSTEM


 In this environment, computation is distributed among several processors. In
  contrast to tightly coupled systems, processors do not share memory or a clock;
  each processor has its own local memory. Processors communicate with one
  another through various communication lines (high speed buses, telephone line).
 Hence they are usually referred to as loosely coupled systems. Processors in a
  distributed system may vary in size and function – small microprocessors,
  workstations, minicomputers, and large general-purpose computer systems.
 Reasons for building distributed systems may include:
     Resource sharing: a user may use resources residing at another site,
     Computation speedup: partitioning a computation across a number of sites or
      moving a computation to another more lightly loaded site (load sharing),
     Reliability: if one site fails other sites can continue operating given that the system
      has sufficient inbuilt redundancy (in both hardware and data),
     Communication: Processes at different sites have the possibility of exchanging
      information; besides users may initiate file transfers or communicate with each other
      via email.
 Note that a distributed system implies a Network system. A network OS is one
  that supports the interconnection of computers that communicate with each
  other and are connected together according to a predefined topology.
                                      Operating Systems                                   16
COMPUTER OPERATION TERMINOLOGY


 On-line operation: this is processing carried out on devices under the
  control of the central processor, while the user remains in
  communication with the computer.
    Example: OS sending a command to a printer to change its present printing
     font.
 Off-line operation: this is processing carried out by devices not under
  the immediate control of the central processing.
    Example: pressing the printer Line Feed button while the printer is off-line.
 Remote Access: It is a form of access where the computer terminal is
  physically separated from the central computer installation.
    Example: work from home through a modem using Telnet.




                                  Operating Systems                             17
FUNCTIONS OF AN OPERATING SYSTEM


 Main functions of an operating system include:
    Process Management : allowing processes to co-exist in the
     system, allocating job priorities, scheduling processor time
    Memory Management: allocating main memory space to each
     process, protecting processes from one another, enabling different
     processes to share the same memory.
    Input/output control: Channelling data to and from peripherals of
     the computer
    File Management: allocating space on secondary storage media,
     keep track of data stored on secondary storage, control file access
     rights and privileges
    Error handling and protection: The detection and reporting of
     errors and minimising their effect. Also it involves protection against
     errors and against deliberate abuse of the system.
                               Operating Systems                        18
STRUCTURE OF OPERATING SYSTEM

 The program structure of an operating system is presented as a
  number of modules:

                              ACCOUNTING

                              PROTECTION

                         RESOURCE ALLOCATION

                      BACKING STORE MANAGEMENT

                              I/O CONTROL

                           MEMORY MANAGEMENT

                                NUCLEUS
                               HARDWARE
                             Operating Systems                     19
NUCLEUS (KERNEL)



 This is the lowest level of an OS. It has direct interaction with the
  hardware. It provides a number of services to the other modules:
 Handling of interrupts
     An interrupt is a signal generated by a source such as some input or
      output device or a system software routine, which causes a break in the
      execution of the current routine. Control passes to another routine in such
      a way that afterwards the original routine may be resumed.
        o Examples of interrupts are information transfer requests, errors
 Co-ordinates the way in which different processes can exist together.
     The OS provides the mechanism for switching the processor from one job
      to another. The OS shares the processor time amongst the different tasks
      in the system in a way so as to maximise processor utilisation
 Allocation of work to the processor
     In many cases more than one job exists in the system at the same time.
      The OS provides the mechanism for switching from one job to another
                                 Operating Systems                             20
MEMORY MANAGEMENT


 The main memory of most computers is too small to handle all programs
  and data all at one time. This part of the OS allocates main memory,
  normally RAM, to programs or parts of programs that need it most.
  Everything else is kept on backing store.
 Virtual memory is a technique used by this layer of the OS. Virtual
  memory is when the computer appears to have more main memory than
  it physically has.
 Caching is a technique used to enhance
  system performance. Some very fast
  memory called Cache memory,
  usually static RAM, is reserved to store
  sections of the executing routines in
  order to take advantage of the short
  access time hence reducing the fetch-
  execute cycle time.
                             Operating Systems                     21
I/O CONTROL


 I/O devices have different characteristics and run at different speeds.
  The OS makes these problems transparent to the user. From a user‟s
  point of view all devices have the same characteristics and are instructed
  in the same way. Thus I/O is DEVICE DEPENDANT from a user‟s point of
  view.
 The OS deals with the physical aspects (e.g. Blocks on disk) of the data
  transfer leaving the programmer free to concentrate on the logical
  aspects of the data structure transferred.
 A very useful output technique (usually used for printing) is SPOOLING.
  Data to be output is held on a spool queue on backing store until the
  output device is ready for it.

         User                                                   Printer
       Program                          Output                 (Output)
                       Output           Queue         Output
                      added to                       removed
                       queue                           from
                                                      queue
                                 Operating Systems                        22
BACKING STORE MANAGEMENT


 The OS has the responsibility of how programs and data are stored in
  secondary memory and ensure that this is being done efficiently.
 Data and programs in backing store are kept in FILES. The OS must
  take care of the creation, deletion and updating of these files.
 Some files are shared; others are
  private. The OS has the
  responsibility of ensuring that
  users respect these ACCESS
  PRIVELEGES.
 Note that this layer of the OS co-
  operates with memory
  management during data transfer
  to/from backing store.


                              Operating Systems                      23
RESOURCE ALLOCATION AND SCHEDULING


 Resources (say, processor, shared files, discs, printers) are usually
  shared by a number of users. The demand for resources is usually
  greater than their availability. Thus some policy must be adopted as to
  which user is to be serviced – resource allocation.
 A FIRST IN FIRST OUT (FIFO) policy is simplest but this could easily
  result in DEADLOCK. Deadlock is when two or more programs prevent
  each other from continuing because each claims a resource that is
  possessed by another. Various policies are enforced to prevent deadlock
  or to recover from it once it occurs.
 Scheduling is mainly concerned with enforcing a policy whereby the
  processor is used efficiently. Its task is to allocate processor time to
  programs. The scheduling algorithm may be as simple as a round-robin
  which deals with each user equally in turn, or as complex as a scheme of
  priorities distinguishing between users and between tasks.

                              Operating Systems                       24
PROTECTION


 The OS should protect the system against errors and
  system malfunction and system abuse.
 The OS should detect and diagnose errors in application
  programs as soon as possible and limit their effects.
 The OS should also protect the software from system
  malfunction. This is achieved by a periodic dump of certain
  files into a suitable backup medium. Also power failure is
  immediately recognised and essential contents of CPU are
  saved on disk before the power has fallen to a level where
  the system has to be shut down. This would only take a
  few milliseconds.
 Protection against abuse is more difficult to deal with.
  Protection mechanisms designed to prevent unauthorised
  activities from succeeding are not always completely
  foolproof.
                              Operating Systems                 25
ACCOUNTING


 An operating system must keep record of
  the changes incurred by each user program
  such as processor time, use of backing
  store, and printer paper.
 Information is passed to the accounting
  module from the scheduler, to establish how
  much processor time a program has used.
 Most multi-user OS‟s take note of the
  number of times a user logs on to/off from a
  system. Some OS s keep track of all actions
  of a user, by logging all his commands to a
  file.
                         Operating Systems       26
COMMUNICATION WITH
                     THE OPERATING SYSTEM


Human communication with the operating system may be of
  two types:
 User mode of operation - between computer and user
    Users communicate with the OS in order to run application
     programs (execute programs) and manage their data files
     (perform housekeeping tasks).
 Supervisor mode of operation -between computer and
  operator
    In supervisor mode, the computer system operator is in ultimate
     control of the system and may override many functions of the OS
     such as switching processor between processes, accessing
     registers used by memory protection hardware, reorganising
     scheduling and resource allocation.

                           Operating Systems                      27
TYPES OF USER INTERFACE


 Different types of user
  interface used by
  different operating                        CLI
  systems.
                                              C:> dir *.exe
 User interfaces may be:
    Command line interface
     (CLI)
    Job-Control Language
    Graphical User Interface
     (GUI)


                            GUI

                                Operating Systems              28
COMMAND LINE INTERFACE (CLI)


 An interactive terminal allows the system to prompt and the user to
  type a command to initiate program execution or housekeeping tasks
    e.g. C:tpuser1>copy myprog1.pas a:
 The user interface module contains a command-line interface (CLI)
  which performs the actual task of identifying and executing the
  command.




                              Operating Systems                         29
GRAPHICAL USER INTERFACE (GUI)



 Using a GUI, the user is presented with pictorial representations
  (ICONS) of the different tasks. The user uses the GUI in conjunction
  with a mouse. Hence initialising a task involves clicking the mouse on
  the required task icon.
 The environment is said to be of the WIMP (Window, Icon, Mouse,
  Pointer) type.
 The main advantages of GUI are:
     ease of use
     user oriented.
 The main disadvantages of GUI are:
     excessive use of main and secondary storage
     slower in executing commands because of much required interpretation
     (require a powerful processor and better graphics display)


                              Operating Systems                          30
JOB-CONTROL LANGUAGE

                                                    E.g. JCL program to
 In this type of environment, the user             compile and execute a
  has no direct interaction with the                COBOL program :
  computer system. The user prepares a
  series of instructions off-line using a         $JOB 123
  JCL to describe to the system the               $PRIORITY 2
  requirements of his/her task.                   $COBOL
 When the user‟s job is eventually               $INPUT PROG1 (DISK 1)
  executed, the execution is guided by            $LIST LP
  the JCL-prepared description. The               $IF ERROR THEN END
  results are then made available at a            $RUN
  later time via some off-line medium say         $MEMORY 250K
  line printer paper.                             $TIME 5
 A job control language is more                  $FILES „PAYFILE‟
  complex and powerful than a command             $IF ERROR THEN DUMP
  language. As from the example above,
                                                  $END
  it is used to write the job description
  i.e. all job control information.
                              Operating Systems                             31
MULTI-PROCESSING



 A program is a sequential set of commands which are
  executed in order by a processor.
 The execution of a program on a processor is called a
  process. Thus if the same program is run twice on the
  same processor, it will be one program but two different
  processes.
 When a machine can have more then one process running
  at the same time, the system is called a multiprocessing
  system.
 A system can have more than one processor, but the
  number of processes running on a machine is generally
  greater then the number of processors.

                       Operating Systems               32
APPLICATION EXAMPLE


 Consider an application program running on a system with one
  processor, one disk and one printer. Part of the program‟s task
  involves reading some data from disk, performing some computation
  on the data, saving the results and printing the result.
      Printer
        Disk

  OS Routine

     Program


                                                                        t
   Request data    Performs      Saves results      Prints    Program
    from disk     Computation       to disk         Results    Ends


                                Operating Systems                           33
CONCURRENCY



 With reference to the example (on previous slide), a lot of
  time is wasted when neither the OS nor the program are
  executing and the processor is free to perform other
  tasks.
 This time can be fruitfully used thanks to concurrency
  where several activities can exist in parallel.
 Concurrency raises problems of:
      Switching from one activity to another.
      Protecting one activity from the effects of another.
      Synchronizing activities which are mutually dependent.
      Control over shared resources.
      Communication between two activities.


                             Operating Systems                  34
CPU SHARING IN CONCURRENT SYSTEMS



 Here several processes share the same CPU and other
  common resources.

              Process 1 is said to be preempted
Process P1

Process P2

Process P3

                                                              Processor
     Context Switching   Process 3 is said to be dispatched     time


                             Operating Systems                       35
PROCESS STATES


    A process can be in one of three states:
         RUNNING (or EXECUTING),
         RUNNABLE (or READY),
         UNRUNNABLE (or BLOCKED)

  Suspended                    dispatched                  Suspended


Activation                                                       Termination
                  READY                           EXECUTING

                               preempted


                SIGNAL                               WAIT
             resource free      BLOCKED          resource busy


                             Operating Systems                         36
SCHEDULING



 Scheduling involves the timing of when to introduce new processes into
  the system ( Activation ) and the order in which processes should run
  or be stopped ( dispatching and preemption ).


                     Ready Queue
 Activation                                   dispatching Execution   Termination
               ...        P3    P2      P1
                                                           on CPU

                          preemption
                                                                        P1    
                                                                        P2   
                                                         Scheduler      P3   
                                                                        P4   


                                   Operating Systems                              37
TYPES OF SCHEDULING



 There are various types of scheduling :
    Preemptive: The running process can be interrupted at any time
     to assign the processor to another process
    Non-Preemptive: A process, once started, can continue running
     until its end.
    Static: scheduling is decided on fixed parameters before the
     scheduling of a process occurs.
    Dynamic: Scheduling decisions are based on dynamic parameters
     and can be changed during program execution.
    Real Time: There are other scheduling techniques used for real
     time operating systems in which the most important factor
     effecting the scheduling is the time constraint.



                            Operating Systems                     38
CRITICAL REGIONS



 When a process tries to access a shared
  resource, which must be used in mutual             P1   P2
  exclusion, the process is said to execute a
  critical region (CR).
 For example suppose that Process P1 and
  Process P2 need to use the same (shared)                CR
  memory location at some time during their          CR
  execution.
 If a process tries to access a resource which is
  already occupied by some other preempted
  process, the scheduler blocks that process and
  sends some other process in execution until the
  shared resource is free. Thus a process stopped
  on a shared resource is said to be blocked.

                              Operating Systems                39
SEMAPHORES


 A hardware or software flag. In
  multitasking systems, a semaphore is a
  variable with a value that indicates the
  status of a common resource. It's used to
  lock the resource that is being used.
 A process needing the resource checks the
  semaphore to determine the resource's
  status and then decides how to proceed.
 For implementation reasons the lock
  (WAIT) and unlock (SIGNAL) must be
  atomic.
 There are various types of semaphores –
  binary, readers/writers … etc.


                             Operating Systems   40
MUTUAL EXCLUSION



 Non-shareable resources, whether peripherals, files, or data in
  memory, can be protected from simultaneous access by several
  processes by preventing the processes from concurrently executing
  the pieces of program through which access is made.
 Exclusion can be achieved by the simple expedient of enclosing each
  critical section by wait and signal operations on a single semaphore
  whose initial value is 1. Thus each critical section is programmed as

           wait (mutex);
                 critical section
           signal(mutex);


                        where mutex is the name of a semaphore.

                             Operating Systems                       41
PROCESS STATE CONTROL


 Thus a process moves in one of the indicated directions:
               Partially completed processes (preempted)


                     Job queue
 New                                                              Termination
 Processes             READY                           C.P.U.
                                       Process
(Activation)                           dispatched
                     Runnable
                                                            Running


                                    Blocked
                                                           wait
                    signal            Semaphore
                                        Queues

                                Operating Systems                         42
PROCESSOR SCHEDULING ALGORITHMS



 Given a set of processes ( or tasks ) = { P1, P2, P3 …Pn}, a
  scheduling algorithm involves a plan for assigning the CPU
  to each process. Among the most popular scheduling
  algorithms which exist are:
      First Come First Served (FCFS)
      Shortest Job First (SJF)
      Priority Scheduling
      Round Robin (RR)
      Multilevel Scheduling




                             Operating Systems             43
FIRST COME FIRST SERVED



 Simplest algorithm implemented by keeping a simple FIFO
  queue, with new processes inserted at the tail of the queue.
 Characteristics of this algorithm:
    Non Preemptive.
    Used mainly for batch non-interactive processes.
    Not used in modern operating system since it offers no real
     concurrent processing.


                      FCFS Queue
    Activation                             Dispatch          Termination
                 P3        P2         P1               CPU




                                   Operating Systems                       44
EXAMPLE FCFS


 Suppose we have 3 processes to be scheduled

                  Process Activation time Execution time
                  P1           3                         4
                  P2           0                         5
                  P3           2                         2

Process P1

Process P2

Process P3

         0    1        2   3       4      5    6     7       8   9   10 11   Processor
                                                                               time
                                       Operating Systems                           45
ROUND ROBIN



 This is particularly suitable for timesharing systems
 Each process is allowed execution for a certain quantum
  of time Q,
    Q must be accurately chosen, in such a way that it is not too
     small to be close to the process commutation time, and not to
     large to leave processes not dispatched for a long time.


  Activation                          Dispatch
                 P3      P1    P2                   CPU   Termination



               Preemptive after a time quantum Q



                              Operating Systems                         46
ROUND-ROBIN


 Suppose we have 3 processes to be scheduled

              Process Activation time Execution time
              P1           2                     4
              P2           0                     5
              P3           4                     2

Process P1

Process P2

Process P3

         0    1    2   3       4      5    6     7     8   9   10 11   Processor
                                                                         time
                                   Operating Systems                         47
PRIORITY SCHEDULING



 Each process is assigned a priority and the process with the highest
  priority is dispatched first. Processes with the same priority are
  dispatched on a FCFS bases.
 One problem in this type of scheduling is starvation, i.e. a process
  with a low priority can wait to be dispatched for an indefinite long
  time, due to higher priority processes.
 One method to avoid starvation is by using aging in which the
  priority of a process is increased dynamically while waiting in the
  queue.
                           FCFS Queues
            Activation
                          P7     P4    P2
 Higher     Activation                                    Termination
                           P6            P5    P1   CPU
 Priority
            Activation
                          P9        P8        P3

                                Operating Systems                        48
EXAMPLE PRIORITY SCHEDULING
                       (NON-PREEMTIVE)


 Suppose we have 3 processes to be scheduled

        Process Priority           Activation time Execution time
        P1        1 (highest)      2                    4
        P2        2                0                    5
        P3        3 (lowest)       4                    2

Process P1

Process P2

Process P3

         0    1   2    3   4       5    6     7     8       9   10 11   Processor
                                                                          time
                                Operating Systems                             49
EXAMPLE PRIORITY SCHEDULING
                          (PREEMTIVE)


 Suppose we have 3 processes to be scheduled

        Process Priority           Activation time Execution time
        P1        1 (highest)      2                    4
        P2        2                0                    5
        P3        3 (lowest)       4                    2

Process P1

Process P2

Process P3

         0    1   2    3   4       5    6     7     8       9   10 11   Processor
                                                                          time
                                Operating Systems                             50
RELOCATION


 The translator does not know where the program will be placed in
  memory when it is executed
 Furthermore, a process may be swapped in and out of memory, so it
  will occupy different physical locations at different times.
 Consequently, the translator cannot assign physical addresses to the
  instructions and data - it must assign logical (or virtual) addresses.
 On the other hand, once programs are loaded, the processor and OS
  must be able to reference the actual physical addresses at which the
  code and data are stored.
 Relocation is the process of converting a logical address to a physical
  address. Its purpose is to let a program be executed from different
  areas of main memory at different times.




                               Operating Systems                            51
ADDRESS TYPES


 A physical address or absolute address
  refers to a physical location in main
  memory.
 A logical address is a reference to a           00000
  memory location independent of the
  physical structure or organization of                       b
                                                          a
  memory.                                         03000
 Compilers produce code in which all                         r
  memory references are expressed as              07000           PROCESS
  logical addresses.
 A relative address is a kind of logical
  address in which the address is expressed
  relative to some known point in the
  program. Usually, the first location is
  address zero and all other addresses are
  offsets from this address.

                              Operating Systems                       52
ADDRESS TRANSLATION


 Programs are loaded in main memory with all memory references in
  relative form
 Physical addresses are calculated “on the fly” as the instructions are
  executed. This process is called address translation, or address
  mapping.
 For adequate performance, the translation from relative to physical
  address must by done by hardware.



 LOGICAL                         ADDRESS                         PHYSICAL
 ADDRESS                       TRANSLATION                       ADDRESS




                               Operating Systems                           53
BASE-LIMIT REGISTER TECHNIQUE


 When a process is dispatched, a base
  register (in the CPU) is loaded with the
  physical start address of the process
  and a bound register is loaded with              03000
  the process‟s ending physical address.            base
 When a relative address is                               r   PROCESS 1
  encountered, add it to the contents of
  the base register to get the actual              09000
  physical address.                                bound
 The physical address is then compared                        PROCESS 2
  to the bound register to make sure the
  process isn‟t referencing a location
  outside its own address space.
 The hardware mechanism provides
  translation and protection.


                               Operating Systems                      54
STRENGTHS AND WEAKNESSES OF BASE-LIMIT REGISTER
                        TECHNIQUE



 The base-and-limit register approach supports dynamic
  relocation, as well as protection and translation, since
  each time the process is dispatched the registers can be
  loaded with the appropriate values.
 However, it works only if the process image is loaded into
  consecutive memory locations.

                                                    Bound



                                                     Base


                        Operating Systems                   55
NON-CONTIGUOUS STORAGE



 Relaxing the assumption that process address space will
  be stored contiguously will let the memory management
  system utilize memory better.
 If portions of processes can be loaded in separate areas
  of memory, compaction will not be necessary.




                        Operating Systems                56
PHYSICAL ORGANIZATION


 Primary memory is fast and expensive.
 Secondary memory is slower and cheaper.
 Consequently, computer systems usually have small amounts of main
  memory and large amounts of disk storage.
 The OS must be responsible for moving information between the two
  levels.
 This is a vital part of memory management.

                             SWAP OUT

               MAIN
              MEMORY                               DISK

                                   SWAP IN

                            Operating Systems                     57
PAGING



 Paging assumes that memory is divided into
  fixed-size chunks, called page frames.
 Process address space is divided into chunks
  called pages.
 Pages are the same size as frames, so a page
  can fit into any free space of memory.
 Each address is composed of 2 parts, a page
  number and an offset. Page numbers are
  concatenated with offset to form the complete
  address.
 The term virtual ( paged ) memory is used to
  describe this system.



                            Operating Systems     58
EXAMPLE OF PROCESS LOADING


 Processes A, B, and C are loaded into memory in order, and assuming
  that the memory is originally empty.




                             Operating Systems                      59
EXAMPLE … CONTINUED



 Now, when B finishes or is
  swapped out a new
  process (D) can be loaded.
 D needs 5 pages; it would
  not fit into either of the
  available free chunks, but
  with paging, we can
  accommodate it.




                        Operating Systems   60
VIRTUAL AND REAL ADDRESSES



 The actual address in memory ( the actual bit pattern
  going in the memory chip ) is called the real address and
  the program address (the one specified by the program) is
  called the virtual address
 A hardware mechanism is used to translate the virtual
  page number to a real page number.
    This mechanism operates only on the pages in main memory.
    If the required page is not in main memory a software program
     must be executed to:
      o Find the required page in secondary memory,
      o Transfer this page into the main memory,
      o Provide space in main memory by choosing the best out block.


                             Operating Systems                         61
PAGED ADDRESS TRANSLATION


                          (Notice that only the
                          page# field changes)




      Operating Systems                           62
PAGE SIZE CONSIDERATIONS


 Page size is typically 512 words.
    If a smaller page is chosen
      o Time taken to transfer pages from main to secondary storage is
        shorter
      o A large selection of pages resides in main memory
      o However it necessitates a large page table.
    For Larger pages:
      o Time taken is longer.
      o A small page table is needed
      o The unused space at the end of each page is likely to increase
        (This is known as internal fragmentation )
 The number of words per page chosen is a compromise.

                             Operating Systems                       63
PAGING & ADDRESS TRANSLATION REMARKS



 Address translation is transparent to the user.
 The OS is responsible for finding enough free frames for a process
  and for creating and initializing the page table.
 Protection is provided by the page table. If the referenced page
  isn‟t part of the process address space, there won‟t be a PT entry.




                            Operating Systems                           64
FILES



 Disk (and tape) provide permanent storage, as opposed to
  the volatile storage in main memory.
 Files are an abstract data type, used to structure data
  stored on a disk.
    Virtually all applications use files for input and output data
    In addition, files hold source code, executables, documents, ….




                            Operating Systems                          65
THE FILE MANAGEMENT SYSTEM



 The file management system provides support to help
  users and applications create, delete, and use files.
 Objectives:
      Provide capability to create and access files.
      Protect validity of data, as much as possible.
      Optimize performance: throughput and response time.
      Interact with multiple users and devices.
      Provide device independent interface.




                            Operating Systems                66
FILE SYSTEM ARCHITECTURE



 File systems extend/expand the layers in the I/O stack
    At the bottom are the device drivers
    The top level provides the access methods, or the interface between
     user and file system.
    Intermediate levels:
      o   maintain directory,
      o   map logical file operations into physical addresses,
      o   allocate disk storage,
      o   provide access control,
      o   manage physical I/O.




                                 Operating Systems                  67
FILE MANAGEMENT FUNCTIONS


 User issues command (read, open, etc.) and the file
  system must:
    Use a directory which describes the location of all files plus their
     attributes
    On a shared system enforce user access controls
    Translate user commands into lower level commands, based on
     access method

 Users access files on a byte
  or record basis; I/O is done
  on a block basis



                               Operating Systems                            68
FILE BLOCKING FUNCTIONS



 Blocking includes
    Allocation of files to free blocks on
     disk
    Management of free storage lists
    scheduling block I/O requests
 Thus files must be divided into
  blocks
 Blocks are the unit of storage
  both on disk and in main-
  memory buffers



                              Operating Systems   69
FILE DIRECTORIES


 Directories provide a mapping between file names and the actual files.
 They contain lists of files and their attributes.
     name
     location (address)
     ownership
 Directories are just special files, owned by the OS.
 The structure of the directory must support at least the following set of
  operations:
       search (to locate a file)
       create
       delete
       list (all or part of the directory)
 When a file is opened, directory information is usually copied from disk
  into a main memory open-file table.

                                       Operating Systems                 70
DIRECTORY STRUCTURE


 Single-level: a list of all files
     slow to search
     requires names to be unique across the entire system
     useful only when there are few files
 Two-level directory
     level two: personal directory for each user
     level one: master directory for entire system
     names unique only within the user directory
 Tree-structured directory
     One-level and two-level directories don‟t give the user any way to structure
      files.
     Tree structured directories allow multiple hierarchical subdirectories in each
      user directory (see Windows and UNIX)
     File names are unique only within a subdirectory
     Pathnames are used to locate files; as in any tree structure, search is fairly
      efficient
                                  Operating Systems                             71
FILE SHARING



 Most file systems allow users to share files, if the owner of
  the file agrees

File sharing introduces
 two issues:
    determining access rights:
     who, besides the owner,
     can modify, execute,
     delete, etc.
    managing simultaneous
     access: what if more than
     one user is trying to access
     a file at the same time?

                            Operating Systems               72
ACCESS CONTROL


 Most common access rights are
     read: user can read and use the file, but can‟t change it
     write: user can modify, delete or add to the file
     execute:user can load and run the program, cannot change
      or copy it
 Other access rights include:
       None
       Knowledge
       Append
       Change protections
       Delete
 Access can be granted to different classes of users:
     individuals
     groups (a set of users, such as class members)
     all (includes everybody with access to the system - e.g.,
      public files)              Operating Systems                73
ACCESS CONTROLS – PRIVILEGES



 A File Management System helps prevent loss, corruption
  and unauthorized access to files.
 The operating system is used to identify and authenticate
  users and their processes.
 The file access is authenticated through id‟s and
  passwords.
 Example:
    UNIX defines three access control types:
      o Read
      o Write

      o Execute


                           Operating Systems             74
FILE SYSTEM RELIABILITY



 For efficiency, many file system structures (or parts of the
  structures) are cached in memory.
    directory info, disk allocation table, etc.
 If the file system updates one of these tables but does not
  save the change to disk, the most current information will
  be lost in a crash.
 Fault Tolerance
    Describes methods of securing file content against hardware
     failure.
    File backup, recovery, and transaction logging are forms or
     protection against disk failure.


                              Operating Systems                    75
FILE BACKUP


 Storing files/directories to different storage device for
  safekeeping purposes
 Protects against data loss, device failure, sabotage, etc.
 Can be automatic or manual
 Types of File Backup
    Full Backup:
      o the FMS copies all files and directories for an entire storage
        volume.
    Incremental Backup:
      o only files that have been modified are archived.
    Differential Backup:
      o only the changed portions of the files are archived.

                               Operating Systems                         76
TRANSACTION LOGGING



 A form of automated file backup.
 A transaction is any single change to
  file contents or attributes.
 All changes are logged (when, by
  whom, etc.).
 Transaction logging provides a high
  degree of protection against data loss
  due to program or hardware failure.
 Lost updates can be recovered from log
  files.
 Imposes performance penalty (every
  change requires two writes - one to file,
  the other to the log).


                              Operating Systems   77
FILE RECOVERY



 The file management
  system maintains backup
  logs to aid in locating
  backup copies of lost or
  damages files.
 The recovery utility
  reconstructs as much of
  the directory and storage
  allocation data structures
  as possible and makes a
  consistency check.


                        Operating Systems   78
MIRRORING



 A fault tolerance technique
  in which all disk write
  operations are made
  simultaneously or
  concurrently to two different
  storage devices.
 Disk mirroring provides a
  high degree of protection
  against data loss with no
  performance penalty if
  implemented in hardware.


                         Operating Systems   79

Weitere ähnliche Inhalte

Was ist angesagt?

11. operating-systems-part-1
11. operating-systems-part-111. operating-systems-part-1
11. operating-systems-part-1Muhammad Ahad
 
Types of computer
Types of computer Types of computer
Types of computer Sajib007
 
OS Components and Structure
OS Components and StructureOS Components and Structure
OS Components and Structuresathish sak
 
Operating Systems - Processor Management
Operating Systems - Processor ManagementOperating Systems - Processor Management
Operating Systems - Processor ManagementDamian T. Gordon
 
Understanding of Computer | Introduction | Computer In Business
Understanding of Computer | Introduction | Computer In BusinessUnderstanding of Computer | Introduction | Computer In Business
Understanding of Computer | Introduction | Computer In BusinessBegum Rokeya University, Rangpur
 
evolution of operating system
evolution of operating systemevolution of operating system
evolution of operating systemAmir Khan
 
Computer System Overview,
Computer System Overview, Computer System Overview,
Computer System Overview, Sajid Marwat
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)Vaibhav Bajaj
 
Operating system presentation
Operating system presentationOperating system presentation
Operating system presentationSonu Vishwakarma
 
Bba203 unit 2 operating system concepts
Bba203   unit 2 operating system conceptsBba203   unit 2 operating system concepts
Bba203 unit 2 operating system conceptskinjal patel
 
Linux process management
Linux process managementLinux process management
Linux process managementRaghu nath
 
introduction To Operating System
introduction To Operating Systemintroduction To Operating System
introduction To Operating SystemLuka M G
 
Operating system support in distributed system
Operating system support in distributed systemOperating system support in distributed system
Operating system support in distributed systemishapadhy
 
Operating system || Chapter 1: Introduction
Operating system || Chapter 1: IntroductionOperating system || Chapter 1: Introduction
Operating system || Chapter 1: IntroductionAnkonGopalBanik
 

Was ist angesagt? (20)

Chapter 2B Peter Norton
Chapter 2B Peter NortonChapter 2B Peter Norton
Chapter 2B Peter Norton
 
Operating system
Operating systemOperating system
Operating system
 
11. operating-systems-part-1
11. operating-systems-part-111. operating-systems-part-1
11. operating-systems-part-1
 
Types of computer
Types of computer Types of computer
Types of computer
 
OS Components and Structure
OS Components and StructureOS Components and Structure
OS Components and Structure
 
Operating Systems - Processor Management
Operating Systems - Processor ManagementOperating Systems - Processor Management
Operating Systems - Processor Management
 
Kernel (OS)
Kernel (OS)Kernel (OS)
Kernel (OS)
 
Understanding of Computer | Introduction | Computer In Business
Understanding of Computer | Introduction | Computer In BusinessUnderstanding of Computer | Introduction | Computer In Business
Understanding of Computer | Introduction | Computer In Business
 
Operating system
Operating systemOperating system
Operating system
 
Chapter 1B Peter Norton
Chapter 1B Peter NortonChapter 1B Peter Norton
Chapter 1B Peter Norton
 
evolution of operating system
evolution of operating systemevolution of operating system
evolution of operating system
 
Computer System Overview,
Computer System Overview, Computer System Overview,
Computer System Overview,
 
Memory management
Memory managementMemory management
Memory management
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)
 
Operating system presentation
Operating system presentationOperating system presentation
Operating system presentation
 
Bba203 unit 2 operating system concepts
Bba203   unit 2 operating system conceptsBba203   unit 2 operating system concepts
Bba203 unit 2 operating system concepts
 
Linux process management
Linux process managementLinux process management
Linux process management
 
introduction To Operating System
introduction To Operating Systemintroduction To Operating System
introduction To Operating System
 
Operating system support in distributed system
Operating system support in distributed systemOperating system support in distributed system
Operating system support in distributed system
 
Operating system || Chapter 1: Introduction
Operating system || Chapter 1: IntroductionOperating system || Chapter 1: Introduction
Operating system || Chapter 1: Introduction
 

Andere mochten auch

Intermediate machine architecture
Intermediate machine architectureIntermediate machine architecture
Intermediate machine architectureJohn Cutajar
 
Functions Of Operating Systems
Functions Of Operating SystemsFunctions Of Operating Systems
Functions Of Operating SystemsAkshay Kurup
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086John Cutajar
 
Understanding operating systems 5th ed ch10
Understanding operating systems 5th ed ch10Understanding operating systems 5th ed ch10
Understanding operating systems 5th ed ch10BarrBoy
 
Understanding operating systems 5th ed ch08
Understanding operating systems 5th ed ch08Understanding operating systems 5th ed ch08
Understanding operating systems 5th ed ch08BarrBoy
 
File implementation
File implementationFile implementation
File implementationMohd Arif
 
Operating Systems
Operating SystemsOperating Systems
Operating SystemsIES Aramo
 
Topic11 sortingandsearching
Topic11 sortingandsearchingTopic11 sortingandsearching
Topic11 sortingandsearchingGopi Saiteja
 
Relational Database Examples
Relational Database ExamplesRelational Database Examples
Relational Database ExamplesJohn Cutajar
 
chapter 2 memory and process management
chapter 2 memory and process managementchapter 2 memory and process management
chapter 2 memory and process managementAisyah Rafiuddin
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediateJohn Cutajar
 

Andere mochten auch (20)

Intermediate machine architecture
Intermediate machine architectureIntermediate machine architecture
Intermediate machine architecture
 
Functions Of Operating Systems
Functions Of Operating SystemsFunctions Of Operating Systems
Functions Of Operating Systems
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
 
Operating system
Operating systemOperating system
Operating system
 
Understanding operating systems 5th ed ch10
Understanding operating systems 5th ed ch10Understanding operating systems 5th ed ch10
Understanding operating systems 5th ed ch10
 
Understanding operating systems 5th ed ch08
Understanding operating systems 5th ed ch08Understanding operating systems 5th ed ch08
Understanding operating systems 5th ed ch08
 
File implementation
File implementationFile implementation
File implementation
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Databases
DatabasesDatabases
Databases
 
Relational
RelationalRelational
Relational
 
SImple SQL
SImple SQLSImple SQL
SImple SQL
 
Topic11 sortingandsearching
Topic11 sortingandsearchingTopic11 sortingandsearching
Topic11 sortingandsearching
 
Relational Database Examples
Relational Database ExamplesRelational Database Examples
Relational Database Examples
 
chapter 2 memory and process management
chapter 2 memory and process managementchapter 2 memory and process management
chapter 2 memory and process management
 
Javanotes
JavanotesJavanotes
Javanotes
 
System design
System designSystem design
System design
 
Module 5 2010
Module 5 2010Module 5 2010
Module 5 2010
 
Oop principles
Oop principlesOop principles
Oop principles
 
Network operating system
Network operating systemNetwork operating system
Network operating system
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediate
 

Ähnlich wie Intermediate Operating Systems

Operting system
Operting systemOperting system
Operting systemKAnurag2
 
Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]Amit Gupta
 
LM1 - Computer System Overview, system calls
LM1 - Computer System Overview, system callsLM1 - Computer System Overview, system calls
LM1 - Computer System Overview, system callsmanideepakc
 
Operating system notes
Operating system notesOperating system notes
Operating system notesSANTOSH RATH
 
MYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptxMYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptxArjayBalberan1
 
Ch1 OS
Ch1 OSCh1 OS
Ch1 OSC.U
 
3330701_unit-1_operating-system-concepts.pdf
3330701_unit-1_operating-system-concepts.pdf3330701_unit-1_operating-system-concepts.pdf
3330701_unit-1_operating-system-concepts.pdfrohitbaweja26
 
Introduction to Operating System
Introduction to Operating SystemIntroduction to Operating System
Introduction to Operating Systempriya_sinha02
 
NE223_chapter 1_Overview of operating systems.ppt
NE223_chapter 1_Overview of operating systems.pptNE223_chapter 1_Overview of operating systems.ppt
NE223_chapter 1_Overview of operating systems.pptMemMem25
 
Operating system 2
Operating system 2Operating system 2
Operating system 2matsapit
 

Ähnlich wie Intermediate Operating Systems (20)

Operting system
Operting systemOperting system
Operting system
 
Unit 1 q&a
Unit  1 q&aUnit  1 q&a
Unit 1 q&a
 
Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]
 
Operating System
Operating SystemOperating System
Operating System
 
LM1 - Computer System Overview, system calls
LM1 - Computer System Overview, system callsLM1 - Computer System Overview, system calls
LM1 - Computer System Overview, system calls
 
Basic os-concepts
Basic os-conceptsBasic os-concepts
Basic os-concepts
 
Operating system notes
Operating system notesOperating system notes
Operating system notes
 
MYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptxMYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptx
 
Ch1 OS
Ch1 OSCh1 OS
Ch1 OS
 
OS_Ch1
OS_Ch1OS_Ch1
OS_Ch1
 
OSCh1
OSCh1OSCh1
OSCh1
 
3330701_unit-1_operating-system-concepts.pdf
3330701_unit-1_operating-system-concepts.pdf3330701_unit-1_operating-system-concepts.pdf
3330701_unit-1_operating-system-concepts.pdf
 
Operating systems
Operating systemsOperating systems
Operating systems
 
Os notes
Os notesOs notes
Os notes
 
Introduction to Operating System
Introduction to Operating SystemIntroduction to Operating System
Introduction to Operating System
 
NE223_chapter 1_Overview of operating systems.ppt
NE223_chapter 1_Overview of operating systems.pptNE223_chapter 1_Overview of operating systems.ppt
NE223_chapter 1_Overview of operating systems.ppt
 
Operating system 2
Operating system 2Operating system 2
Operating system 2
 
Introduction to OS 1.ppt
Introduction to OS 1.pptIntroduction to OS 1.ppt
Introduction to OS 1.ppt
 
Operating systems
Operating systems Operating systems
Operating systems
 
Compyter system softwere
Compyter system softwereCompyter system softwere
Compyter system softwere
 

Kürzlich hochgeladen

Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 

Kürzlich hochgeladen (20)

Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 

Intermediate Operating Systems

  • 1. MODULE 5 OPERATING SYSTEM Intermediate Level © Cutajar & Cutajar 2009
  • 2. WHAT IS AN OPERATING SYSTEM  An OPERATING SYSTEM (OS) is set of programs that manage all the hardware resources of a computer system, thus isolating the user from the complexities of direct use of the computer hardware.  The operating system manages resources such as:  input (keyboard, mouse, ),  processing (CPU, … ),  storage (main memory, hard discs, floppy discs, … )  output ( monitor, printer, … ).  It controls the way in which these resources are put to work. Operating Systems 2
  • 3. ROLE OF THE OPERATING SYSTEM User Interface Hardware User OS Function Call Interface Operating Systems 3
  • 4. COMPUTER SYSTEM HIERARCHY  The computer system hierarchy : User 1 User 2  User n Compiler database word  System processor System and application programs Operating System Computer Hardware Operating Systems 4
  • 5. LOADING AN OPERATING SYSTEM  The operating system is usually held on disk and has to be loaded into main memory once the computer is switched on before any other program can be run. Exception: In very compact systems, the OS may be held in ROM.  The process of loading the operating system is called BOOTING the system.  The BOOTSTRAP LOADER is an initial small program that executes itself once the system is powered on. This loader is held in ROM. It tells the computer where to look for the operating system and gives instructions to load at least part of it into memory.  Once part of the OS has been loaded, more instructions can be executed to load the rest of the OS kernel (nucleus).  The operating system then waits for some event to occur. Operating Systems 5
  • 6. OBJECTIVES OF AN OPERATING SYSTEM 1. To make it possible for the resources of the computer to be used efficiently.  Efficient resource utilisation is made especially difficult by the fact that some devices of a computer work much more quickly than others. Part of the task of the operating system is to ensure that fast devices such as processors, are not held up by slower peripheral devices. Thus the operating system is responsible for allocating and controlling use of all resources of a computer system. 2. To conceal the difficulties of dealing directly with the hardware of the computer.  To simplify the use of the hardware of a computer, the OS creates a VIRTUAL MACHINE i.e. it takes care of the hardware difficulties presented by the different component devices of the computer system and provides the user with a simplified computer environment. Thus a computer user need only know about (and how to operate) the „virtual machine‟. Operating Systems 6
  • 7. DESIRABLE FEATURES OF OPERATING SYSTEMS  Efficiency  An OS must carry out its tasks promptly. Time spent on operating system functions is productive time wasted.  Reliability  Failure in an OS can render the host computer useless. An OS program should do what it has to do correctly. Ideally the OS should be error free and able to handle all contingencies - robustness.  Maintainability  Clearly written, well-structured (operating system) programs are essential for any later modifications. This is a very complex set of programs to develop; it is costly to produce (hence well-structuring and modularity encourage the reusability of code). Also remember that maintenance is the most costly part of any software existence cycle, hence having features which enhance maintainability help keep maintenance costs down.  Small Size  Space used to hold the OS whether in main memory or on backing store is wasted as far as productive computing is concerned. Operating Systems 7
  • 8. TYPES OF OPERATING SYSTEMS  Operational mode is the form of operational organisation which determines the way in which the computer system is being used. This is determined by the operating system which is currently controlling the computer.  Batch  Online  Multiprogramming (multitasking)  Time-sharing (multi-access)  Single-user  Real-time o Hard real-time (process control) o Soft real-time (transaction processing) Operating Systems 8
  • 9. BATCH  A number of programs are batched together and run as a group. Although the programs are run one at a time, input and output from various programs can overlap to some extent.  Programs are usually queued up for batch processing and the operating system starts the next program in the queue as soon as sufficient computing resources are available for it. Some application area examples are payroll, processing of utility bills and master file updating process.  The main characteristic of batch processing is the lack of interaction between the user and the job while the job is executing.  Note that the above set up with the interleaving of batch jobs is better known as multiprogrammed batched system as against the simpler batch type where jobs are run one after the other. Multiprogrammed batch systems were facilitated by technological development. This set-up ensures better utilisation of the resources, the CPU in particular. Operating Systems 9
  • 10. MULTIPROGRAMMING (MULTITASKING)  At any one time, a number of programs are on the computer at various stages of completion. (Remember multi-programmed batch systems!). UNI CPU idle  Resources are allocated to programs according to the requirements of the programs and in order to maximise the usage of the resources of the computer.  Having multiple jobs running concurrently on the same system implies more demanding operating system functions MULTI such as process scheduling, memory management and system security and protection.  It also implies better utilisation of CPU idle computer resources. time Operating Systems 10
  • 11. TIME-SHARING (MULTI-ACCESS)  Time-sharing systems are a logical extension of multiprogramming systems. The operating system allows many users to use the computer at apparently the same time.  Each job on the computer is given a quantum of processing time. The CPU switches from one job to another so quickly that each user is given the impression that s/he has her own computer, whereas actually one computer is being shared by several users.  Time-sharing systems make possible the interactive use of multi- programmed computer systems. In this environment, the user gives instructions to the computer and immediately receives a response.  Most operating systems provide both batch processing and time- sharing (although their basic design is either one or the other). Operating Systems 11
  • 12. REAL-TIME SYSTEM  A real-time system is used when there are rigid time requirements on the operation of a processor or the flow of data such as systems that control scientific experiments, medical imaging systems, industrial control systems, some display systems, home-appliance controllers, weapon systems.  They can be classified in:  Hard real-time (Real-time process control)  Soft real-time (Real-time transaction processing) BOOM! HARD SOFT deadline time Operating Systems 12
  • 13. REAL-TIME PROCESS CONTROL  Real-time process control systems require that all delays are bounded, from the retrieval of stored data to the time that it takes the operating system to finish any request made of it.  Such time constraints dictate the facilities that are available in hard real-time systems - secondary storage is either missing or very limited, virtual memory is non-existent, advanced OS features separating user from hardware are absent.  Hard real-time systems cannot be mixed with the operation of time-sharing systems (and any general purpose operating system) because of conflicting features. Operating Systems 13
  • 14. REAL-TIME ONLINE TRANSACTION PROCESSING  Online Transaction Processing (OLTP) systems are less restrictive. A critical real-time task gets priority over other tasks and retains that priority until it completes. This type of real-time system may be mixed with other types of systems. (Application areas include interactive database applications, multimedia presentations, virtual reality, ) Operating Systems 14
  • 15. PARALLEL (MULTIPROCESSOR) SYSTEM  Computer systems having more than one processor enjoy increased throughput (more work is done in a shorter period of time), increased reliability (failure of one processor will not halt the system - the ability to continue providing service proportional to the level of surviving hardware is called graceful degradation – systems designed for graceful degradation are called fault tolerant)  Processors share the computer bus, the clock, memory and peripheral devices and are referred to as tightly coupled systems. Operating Systems 15
  • 16. DISTRIBUTED SYSTEM  In this environment, computation is distributed among several processors. In contrast to tightly coupled systems, processors do not share memory or a clock; each processor has its own local memory. Processors communicate with one another through various communication lines (high speed buses, telephone line).  Hence they are usually referred to as loosely coupled systems. Processors in a distributed system may vary in size and function – small microprocessors, workstations, minicomputers, and large general-purpose computer systems.  Reasons for building distributed systems may include:  Resource sharing: a user may use resources residing at another site,  Computation speedup: partitioning a computation across a number of sites or moving a computation to another more lightly loaded site (load sharing),  Reliability: if one site fails other sites can continue operating given that the system has sufficient inbuilt redundancy (in both hardware and data),  Communication: Processes at different sites have the possibility of exchanging information; besides users may initiate file transfers or communicate with each other via email.  Note that a distributed system implies a Network system. A network OS is one that supports the interconnection of computers that communicate with each other and are connected together according to a predefined topology. Operating Systems 16
  • 17. COMPUTER OPERATION TERMINOLOGY  On-line operation: this is processing carried out on devices under the control of the central processor, while the user remains in communication with the computer.  Example: OS sending a command to a printer to change its present printing font.  Off-line operation: this is processing carried out by devices not under the immediate control of the central processing.  Example: pressing the printer Line Feed button while the printer is off-line.  Remote Access: It is a form of access where the computer terminal is physically separated from the central computer installation.  Example: work from home through a modem using Telnet. Operating Systems 17
  • 18. FUNCTIONS OF AN OPERATING SYSTEM  Main functions of an operating system include:  Process Management : allowing processes to co-exist in the system, allocating job priorities, scheduling processor time  Memory Management: allocating main memory space to each process, protecting processes from one another, enabling different processes to share the same memory.  Input/output control: Channelling data to and from peripherals of the computer  File Management: allocating space on secondary storage media, keep track of data stored on secondary storage, control file access rights and privileges  Error handling and protection: The detection and reporting of errors and minimising their effect. Also it involves protection against errors and against deliberate abuse of the system. Operating Systems 18
  • 19. STRUCTURE OF OPERATING SYSTEM  The program structure of an operating system is presented as a number of modules: ACCOUNTING PROTECTION RESOURCE ALLOCATION BACKING STORE MANAGEMENT I/O CONTROL MEMORY MANAGEMENT NUCLEUS HARDWARE Operating Systems 19
  • 20. NUCLEUS (KERNEL)  This is the lowest level of an OS. It has direct interaction with the hardware. It provides a number of services to the other modules:  Handling of interrupts  An interrupt is a signal generated by a source such as some input or output device or a system software routine, which causes a break in the execution of the current routine. Control passes to another routine in such a way that afterwards the original routine may be resumed. o Examples of interrupts are information transfer requests, errors  Co-ordinates the way in which different processes can exist together.  The OS provides the mechanism for switching the processor from one job to another. The OS shares the processor time amongst the different tasks in the system in a way so as to maximise processor utilisation  Allocation of work to the processor  In many cases more than one job exists in the system at the same time. The OS provides the mechanism for switching from one job to another Operating Systems 20
  • 21. MEMORY MANAGEMENT  The main memory of most computers is too small to handle all programs and data all at one time. This part of the OS allocates main memory, normally RAM, to programs or parts of programs that need it most. Everything else is kept on backing store.  Virtual memory is a technique used by this layer of the OS. Virtual memory is when the computer appears to have more main memory than it physically has.  Caching is a technique used to enhance system performance. Some very fast memory called Cache memory, usually static RAM, is reserved to store sections of the executing routines in order to take advantage of the short access time hence reducing the fetch- execute cycle time. Operating Systems 21
  • 22. I/O CONTROL  I/O devices have different characteristics and run at different speeds. The OS makes these problems transparent to the user. From a user‟s point of view all devices have the same characteristics and are instructed in the same way. Thus I/O is DEVICE DEPENDANT from a user‟s point of view.  The OS deals with the physical aspects (e.g. Blocks on disk) of the data transfer leaving the programmer free to concentrate on the logical aspects of the data structure transferred.  A very useful output technique (usually used for printing) is SPOOLING. Data to be output is held on a spool queue on backing store until the output device is ready for it. User Printer Program Output (Output) Output Queue Output added to removed queue from queue Operating Systems 22
  • 23. BACKING STORE MANAGEMENT  The OS has the responsibility of how programs and data are stored in secondary memory and ensure that this is being done efficiently.  Data and programs in backing store are kept in FILES. The OS must take care of the creation, deletion and updating of these files.  Some files are shared; others are private. The OS has the responsibility of ensuring that users respect these ACCESS PRIVELEGES.  Note that this layer of the OS co- operates with memory management during data transfer to/from backing store. Operating Systems 23
  • 24. RESOURCE ALLOCATION AND SCHEDULING  Resources (say, processor, shared files, discs, printers) are usually shared by a number of users. The demand for resources is usually greater than their availability. Thus some policy must be adopted as to which user is to be serviced – resource allocation.  A FIRST IN FIRST OUT (FIFO) policy is simplest but this could easily result in DEADLOCK. Deadlock is when two or more programs prevent each other from continuing because each claims a resource that is possessed by another. Various policies are enforced to prevent deadlock or to recover from it once it occurs.  Scheduling is mainly concerned with enforcing a policy whereby the processor is used efficiently. Its task is to allocate processor time to programs. The scheduling algorithm may be as simple as a round-robin which deals with each user equally in turn, or as complex as a scheme of priorities distinguishing between users and between tasks. Operating Systems 24
  • 25. PROTECTION  The OS should protect the system against errors and system malfunction and system abuse.  The OS should detect and diagnose errors in application programs as soon as possible and limit their effects.  The OS should also protect the software from system malfunction. This is achieved by a periodic dump of certain files into a suitable backup medium. Also power failure is immediately recognised and essential contents of CPU are saved on disk before the power has fallen to a level where the system has to be shut down. This would only take a few milliseconds.  Protection against abuse is more difficult to deal with. Protection mechanisms designed to prevent unauthorised activities from succeeding are not always completely foolproof. Operating Systems 25
  • 26. ACCOUNTING  An operating system must keep record of the changes incurred by each user program such as processor time, use of backing store, and printer paper.  Information is passed to the accounting module from the scheduler, to establish how much processor time a program has used.  Most multi-user OS‟s take note of the number of times a user logs on to/off from a system. Some OS s keep track of all actions of a user, by logging all his commands to a file. Operating Systems 26
  • 27. COMMUNICATION WITH THE OPERATING SYSTEM Human communication with the operating system may be of two types:  User mode of operation - between computer and user  Users communicate with the OS in order to run application programs (execute programs) and manage their data files (perform housekeeping tasks).  Supervisor mode of operation -between computer and operator  In supervisor mode, the computer system operator is in ultimate control of the system and may override many functions of the OS such as switching processor between processes, accessing registers used by memory protection hardware, reorganising scheduling and resource allocation. Operating Systems 27
  • 28. TYPES OF USER INTERFACE  Different types of user interface used by different operating CLI systems. C:> dir *.exe  User interfaces may be:  Command line interface (CLI)  Job-Control Language  Graphical User Interface (GUI) GUI Operating Systems 28
  • 29. COMMAND LINE INTERFACE (CLI)  An interactive terminal allows the system to prompt and the user to type a command to initiate program execution or housekeeping tasks  e.g. C:tpuser1>copy myprog1.pas a:  The user interface module contains a command-line interface (CLI) which performs the actual task of identifying and executing the command. Operating Systems 29
  • 30. GRAPHICAL USER INTERFACE (GUI)  Using a GUI, the user is presented with pictorial representations (ICONS) of the different tasks. The user uses the GUI in conjunction with a mouse. Hence initialising a task involves clicking the mouse on the required task icon.  The environment is said to be of the WIMP (Window, Icon, Mouse, Pointer) type.  The main advantages of GUI are:  ease of use  user oriented.  The main disadvantages of GUI are:  excessive use of main and secondary storage  slower in executing commands because of much required interpretation  (require a powerful processor and better graphics display) Operating Systems 30
  • 31. JOB-CONTROL LANGUAGE E.g. JCL program to  In this type of environment, the user compile and execute a has no direct interaction with the COBOL program : computer system. The user prepares a series of instructions off-line using a $JOB 123 JCL to describe to the system the $PRIORITY 2 requirements of his/her task. $COBOL  When the user‟s job is eventually $INPUT PROG1 (DISK 1) executed, the execution is guided by $LIST LP the JCL-prepared description. The $IF ERROR THEN END results are then made available at a $RUN later time via some off-line medium say $MEMORY 250K line printer paper. $TIME 5  A job control language is more $FILES „PAYFILE‟ complex and powerful than a command $IF ERROR THEN DUMP language. As from the example above, $END it is used to write the job description i.e. all job control information. Operating Systems 31
  • 32. MULTI-PROCESSING  A program is a sequential set of commands which are executed in order by a processor.  The execution of a program on a processor is called a process. Thus if the same program is run twice on the same processor, it will be one program but two different processes.  When a machine can have more then one process running at the same time, the system is called a multiprocessing system.  A system can have more than one processor, but the number of processes running on a machine is generally greater then the number of processors. Operating Systems 32
  • 33. APPLICATION EXAMPLE  Consider an application program running on a system with one processor, one disk and one printer. Part of the program‟s task involves reading some data from disk, performing some computation on the data, saving the results and printing the result. Printer Disk OS Routine Program t Request data Performs Saves results Prints Program from disk Computation to disk Results Ends Operating Systems 33
  • 34. CONCURRENCY  With reference to the example (on previous slide), a lot of time is wasted when neither the OS nor the program are executing and the processor is free to perform other tasks.  This time can be fruitfully used thanks to concurrency where several activities can exist in parallel.  Concurrency raises problems of:  Switching from one activity to another.  Protecting one activity from the effects of another.  Synchronizing activities which are mutually dependent.  Control over shared resources.  Communication between two activities. Operating Systems 34
  • 35. CPU SHARING IN CONCURRENT SYSTEMS  Here several processes share the same CPU and other common resources. Process 1 is said to be preempted Process P1 Process P2 Process P3 Processor Context Switching Process 3 is said to be dispatched time Operating Systems 35
  • 36. PROCESS STATES  A process can be in one of three states:  RUNNING (or EXECUTING),  RUNNABLE (or READY),  UNRUNNABLE (or BLOCKED) Suspended dispatched Suspended Activation Termination READY EXECUTING preempted SIGNAL WAIT resource free BLOCKED resource busy Operating Systems 36
  • 37. SCHEDULING  Scheduling involves the timing of when to introduce new processes into the system ( Activation ) and the order in which processes should run or be stopped ( dispatching and preemption ). Ready Queue Activation dispatching Execution Termination ... P3 P2 P1 on CPU preemption P1  P2  Scheduler P3  P4  Operating Systems 37
  • 38. TYPES OF SCHEDULING  There are various types of scheduling :  Preemptive: The running process can be interrupted at any time to assign the processor to another process  Non-Preemptive: A process, once started, can continue running until its end.  Static: scheduling is decided on fixed parameters before the scheduling of a process occurs.  Dynamic: Scheduling decisions are based on dynamic parameters and can be changed during program execution.  Real Time: There are other scheduling techniques used for real time operating systems in which the most important factor effecting the scheduling is the time constraint. Operating Systems 38
  • 39. CRITICAL REGIONS  When a process tries to access a shared resource, which must be used in mutual P1 P2 exclusion, the process is said to execute a critical region (CR).  For example suppose that Process P1 and Process P2 need to use the same (shared) CR memory location at some time during their CR execution.  If a process tries to access a resource which is already occupied by some other preempted process, the scheduler blocks that process and sends some other process in execution until the shared resource is free. Thus a process stopped on a shared resource is said to be blocked. Operating Systems 39
  • 40. SEMAPHORES  A hardware or software flag. In multitasking systems, a semaphore is a variable with a value that indicates the status of a common resource. It's used to lock the resource that is being used.  A process needing the resource checks the semaphore to determine the resource's status and then decides how to proceed.  For implementation reasons the lock (WAIT) and unlock (SIGNAL) must be atomic.  There are various types of semaphores – binary, readers/writers … etc. Operating Systems 40
  • 41. MUTUAL EXCLUSION  Non-shareable resources, whether peripherals, files, or data in memory, can be protected from simultaneous access by several processes by preventing the processes from concurrently executing the pieces of program through which access is made.  Exclusion can be achieved by the simple expedient of enclosing each critical section by wait and signal operations on a single semaphore whose initial value is 1. Thus each critical section is programmed as wait (mutex); critical section signal(mutex); where mutex is the name of a semaphore. Operating Systems 41
  • 42. PROCESS STATE CONTROL  Thus a process moves in one of the indicated directions: Partially completed processes (preempted) Job queue New Termination Processes READY C.P.U. Process (Activation) dispatched Runnable Running Blocked wait signal Semaphore Queues Operating Systems 42
  • 43. PROCESSOR SCHEDULING ALGORITHMS  Given a set of processes ( or tasks ) = { P1, P2, P3 …Pn}, a scheduling algorithm involves a plan for assigning the CPU to each process. Among the most popular scheduling algorithms which exist are:  First Come First Served (FCFS)  Shortest Job First (SJF)  Priority Scheduling  Round Robin (RR)  Multilevel Scheduling Operating Systems 43
  • 44. FIRST COME FIRST SERVED  Simplest algorithm implemented by keeping a simple FIFO queue, with new processes inserted at the tail of the queue.  Characteristics of this algorithm:  Non Preemptive.  Used mainly for batch non-interactive processes.  Not used in modern operating system since it offers no real concurrent processing. FCFS Queue Activation Dispatch Termination P3 P2 P1 CPU Operating Systems 44
  • 45. EXAMPLE FCFS  Suppose we have 3 processes to be scheduled Process Activation time Execution time P1 3 4 P2 0 5 P3 2 2 Process P1 Process P2 Process P3 0 1 2 3 4 5 6 7 8 9 10 11 Processor time Operating Systems 45
  • 46. ROUND ROBIN  This is particularly suitable for timesharing systems  Each process is allowed execution for a certain quantum of time Q,  Q must be accurately chosen, in such a way that it is not too small to be close to the process commutation time, and not to large to leave processes not dispatched for a long time. Activation Dispatch P3 P1 P2 CPU Termination Preemptive after a time quantum Q Operating Systems 46
  • 47. ROUND-ROBIN  Suppose we have 3 processes to be scheduled Process Activation time Execution time P1 2 4 P2 0 5 P3 4 2 Process P1 Process P2 Process P3 0 1 2 3 4 5 6 7 8 9 10 11 Processor time Operating Systems 47
  • 48. PRIORITY SCHEDULING  Each process is assigned a priority and the process with the highest priority is dispatched first. Processes with the same priority are dispatched on a FCFS bases.  One problem in this type of scheduling is starvation, i.e. a process with a low priority can wait to be dispatched for an indefinite long time, due to higher priority processes.  One method to avoid starvation is by using aging in which the priority of a process is increased dynamically while waiting in the queue. FCFS Queues Activation P7 P4 P2 Higher Activation Termination P6 P5 P1 CPU Priority Activation P9 P8 P3 Operating Systems 48
  • 49. EXAMPLE PRIORITY SCHEDULING (NON-PREEMTIVE)  Suppose we have 3 processes to be scheduled Process Priority Activation time Execution time P1 1 (highest) 2 4 P2 2 0 5 P3 3 (lowest) 4 2 Process P1 Process P2 Process P3 0 1 2 3 4 5 6 7 8 9 10 11 Processor time Operating Systems 49
  • 50. EXAMPLE PRIORITY SCHEDULING (PREEMTIVE)  Suppose we have 3 processes to be scheduled Process Priority Activation time Execution time P1 1 (highest) 2 4 P2 2 0 5 P3 3 (lowest) 4 2 Process P1 Process P2 Process P3 0 1 2 3 4 5 6 7 8 9 10 11 Processor time Operating Systems 50
  • 51. RELOCATION  The translator does not know where the program will be placed in memory when it is executed  Furthermore, a process may be swapped in and out of memory, so it will occupy different physical locations at different times.  Consequently, the translator cannot assign physical addresses to the instructions and data - it must assign logical (or virtual) addresses.  On the other hand, once programs are loaded, the processor and OS must be able to reference the actual physical addresses at which the code and data are stored.  Relocation is the process of converting a logical address to a physical address. Its purpose is to let a program be executed from different areas of main memory at different times. Operating Systems 51
  • 52. ADDRESS TYPES  A physical address or absolute address refers to a physical location in main memory.  A logical address is a reference to a 00000 memory location independent of the physical structure or organization of b a memory. 03000  Compilers produce code in which all r memory references are expressed as 07000 PROCESS logical addresses.  A relative address is a kind of logical address in which the address is expressed relative to some known point in the program. Usually, the first location is address zero and all other addresses are offsets from this address. Operating Systems 52
  • 53. ADDRESS TRANSLATION  Programs are loaded in main memory with all memory references in relative form  Physical addresses are calculated “on the fly” as the instructions are executed. This process is called address translation, or address mapping.  For adequate performance, the translation from relative to physical address must by done by hardware. LOGICAL ADDRESS PHYSICAL ADDRESS TRANSLATION ADDRESS Operating Systems 53
  • 54. BASE-LIMIT REGISTER TECHNIQUE  When a process is dispatched, a base register (in the CPU) is loaded with the physical start address of the process and a bound register is loaded with 03000 the process‟s ending physical address. base  When a relative address is r PROCESS 1 encountered, add it to the contents of the base register to get the actual 09000 physical address. bound  The physical address is then compared PROCESS 2 to the bound register to make sure the process isn‟t referencing a location outside its own address space.  The hardware mechanism provides translation and protection. Operating Systems 54
  • 55. STRENGTHS AND WEAKNESSES OF BASE-LIMIT REGISTER TECHNIQUE  The base-and-limit register approach supports dynamic relocation, as well as protection and translation, since each time the process is dispatched the registers can be loaded with the appropriate values.  However, it works only if the process image is loaded into consecutive memory locations. Bound Base Operating Systems 55
  • 56. NON-CONTIGUOUS STORAGE  Relaxing the assumption that process address space will be stored contiguously will let the memory management system utilize memory better.  If portions of processes can be loaded in separate areas of memory, compaction will not be necessary. Operating Systems 56
  • 57. PHYSICAL ORGANIZATION  Primary memory is fast and expensive.  Secondary memory is slower and cheaper.  Consequently, computer systems usually have small amounts of main memory and large amounts of disk storage.  The OS must be responsible for moving information between the two levels.  This is a vital part of memory management. SWAP OUT MAIN MEMORY DISK SWAP IN Operating Systems 57
  • 58. PAGING  Paging assumes that memory is divided into fixed-size chunks, called page frames.  Process address space is divided into chunks called pages.  Pages are the same size as frames, so a page can fit into any free space of memory.  Each address is composed of 2 parts, a page number and an offset. Page numbers are concatenated with offset to form the complete address.  The term virtual ( paged ) memory is used to describe this system. Operating Systems 58
  • 59. EXAMPLE OF PROCESS LOADING  Processes A, B, and C are loaded into memory in order, and assuming that the memory is originally empty. Operating Systems 59
  • 60. EXAMPLE … CONTINUED  Now, when B finishes or is swapped out a new process (D) can be loaded.  D needs 5 pages; it would not fit into either of the available free chunks, but with paging, we can accommodate it. Operating Systems 60
  • 61. VIRTUAL AND REAL ADDRESSES  The actual address in memory ( the actual bit pattern going in the memory chip ) is called the real address and the program address (the one specified by the program) is called the virtual address  A hardware mechanism is used to translate the virtual page number to a real page number.  This mechanism operates only on the pages in main memory.  If the required page is not in main memory a software program must be executed to: o Find the required page in secondary memory, o Transfer this page into the main memory, o Provide space in main memory by choosing the best out block. Operating Systems 61
  • 62. PAGED ADDRESS TRANSLATION (Notice that only the page# field changes) Operating Systems 62
  • 63. PAGE SIZE CONSIDERATIONS  Page size is typically 512 words.  If a smaller page is chosen o Time taken to transfer pages from main to secondary storage is shorter o A large selection of pages resides in main memory o However it necessitates a large page table.  For Larger pages: o Time taken is longer. o A small page table is needed o The unused space at the end of each page is likely to increase (This is known as internal fragmentation )  The number of words per page chosen is a compromise. Operating Systems 63
  • 64. PAGING & ADDRESS TRANSLATION REMARKS  Address translation is transparent to the user.  The OS is responsible for finding enough free frames for a process and for creating and initializing the page table.  Protection is provided by the page table. If the referenced page isn‟t part of the process address space, there won‟t be a PT entry. Operating Systems 64
  • 65. FILES  Disk (and tape) provide permanent storage, as opposed to the volatile storage in main memory.  Files are an abstract data type, used to structure data stored on a disk.  Virtually all applications use files for input and output data  In addition, files hold source code, executables, documents, …. Operating Systems 65
  • 66. THE FILE MANAGEMENT SYSTEM  The file management system provides support to help users and applications create, delete, and use files.  Objectives:  Provide capability to create and access files.  Protect validity of data, as much as possible.  Optimize performance: throughput and response time.  Interact with multiple users and devices.  Provide device independent interface. Operating Systems 66
  • 67. FILE SYSTEM ARCHITECTURE  File systems extend/expand the layers in the I/O stack  At the bottom are the device drivers  The top level provides the access methods, or the interface between user and file system.  Intermediate levels: o maintain directory, o map logical file operations into physical addresses, o allocate disk storage, o provide access control, o manage physical I/O. Operating Systems 67
  • 68. FILE MANAGEMENT FUNCTIONS  User issues command (read, open, etc.) and the file system must:  Use a directory which describes the location of all files plus their attributes  On a shared system enforce user access controls  Translate user commands into lower level commands, based on access method  Users access files on a byte or record basis; I/O is done on a block basis Operating Systems 68
  • 69. FILE BLOCKING FUNCTIONS  Blocking includes  Allocation of files to free blocks on disk  Management of free storage lists  scheduling block I/O requests  Thus files must be divided into blocks  Blocks are the unit of storage both on disk and in main- memory buffers Operating Systems 69
  • 70. FILE DIRECTORIES  Directories provide a mapping between file names and the actual files.  They contain lists of files and their attributes.  name  location (address)  ownership  Directories are just special files, owned by the OS.  The structure of the directory must support at least the following set of operations:  search (to locate a file)  create  delete  list (all or part of the directory)  When a file is opened, directory information is usually copied from disk into a main memory open-file table. Operating Systems 70
  • 71. DIRECTORY STRUCTURE  Single-level: a list of all files  slow to search  requires names to be unique across the entire system  useful only when there are few files  Two-level directory  level two: personal directory for each user  level one: master directory for entire system  names unique only within the user directory  Tree-structured directory  One-level and two-level directories don‟t give the user any way to structure files.  Tree structured directories allow multiple hierarchical subdirectories in each user directory (see Windows and UNIX)  File names are unique only within a subdirectory  Pathnames are used to locate files; as in any tree structure, search is fairly efficient Operating Systems 71
  • 72. FILE SHARING  Most file systems allow users to share files, if the owner of the file agrees File sharing introduces two issues:  determining access rights: who, besides the owner, can modify, execute, delete, etc.  managing simultaneous access: what if more than one user is trying to access a file at the same time? Operating Systems 72
  • 73. ACCESS CONTROL  Most common access rights are  read: user can read and use the file, but can‟t change it  write: user can modify, delete or add to the file  execute:user can load and run the program, cannot change or copy it  Other access rights include:  None  Knowledge  Append  Change protections  Delete  Access can be granted to different classes of users:  individuals  groups (a set of users, such as class members)  all (includes everybody with access to the system - e.g., public files) Operating Systems 73
  • 74. ACCESS CONTROLS – PRIVILEGES  A File Management System helps prevent loss, corruption and unauthorized access to files.  The operating system is used to identify and authenticate users and their processes.  The file access is authenticated through id‟s and passwords.  Example:  UNIX defines three access control types: o Read o Write o Execute Operating Systems 74
  • 75. FILE SYSTEM RELIABILITY  For efficiency, many file system structures (or parts of the structures) are cached in memory.  directory info, disk allocation table, etc.  If the file system updates one of these tables but does not save the change to disk, the most current information will be lost in a crash.  Fault Tolerance  Describes methods of securing file content against hardware failure.  File backup, recovery, and transaction logging are forms or protection against disk failure. Operating Systems 75
  • 76. FILE BACKUP  Storing files/directories to different storage device for safekeeping purposes  Protects against data loss, device failure, sabotage, etc.  Can be automatic or manual  Types of File Backup  Full Backup: o the FMS copies all files and directories for an entire storage volume.  Incremental Backup: o only files that have been modified are archived.  Differential Backup: o only the changed portions of the files are archived. Operating Systems 76
  • 77. TRANSACTION LOGGING  A form of automated file backup.  A transaction is any single change to file contents or attributes.  All changes are logged (when, by whom, etc.).  Transaction logging provides a high degree of protection against data loss due to program or hardware failure.  Lost updates can be recovered from log files.  Imposes performance penalty (every change requires two writes - one to file, the other to the log). Operating Systems 77
  • 78. FILE RECOVERY  The file management system maintains backup logs to aid in locating backup copies of lost or damages files.  The recovery utility reconstructs as much of the directory and storage allocation data structures as possible and makes a consistency check. Operating Systems 78
  • 79. MIRRORING  A fault tolerance technique in which all disk write operations are made simultaneously or concurrently to two different storage devices.  Disk mirroring provides a high degree of protection against data loss with no performance penalty if implemented in hardware. Operating Systems 79