Operating system answerkey-1st internaldoc - SNGCE DIGITAL

Document Sample
Operating system answerkey-1st internaldoc - SNGCE DIGITAL Powered By Docstoc
					                  SREE NARAYANA GURUKULAM COLLEGE OF ENGINEERING
                         5th Semester Computer Science and Engineering
                               First series examination-August 2009
                                    Operating Systems(RT 502)

                                                             Time:2 Hours
                                                                Max.Marks:60

                                                  PART A
           Each question carries 4 marks

     1.    Define operating system. Explain the fundamental principle of operation of a computer system.
     2.    What is meant by real time operating system?
     3.    With a neat sketch,explain the different process states.
     4.    Differentiate between thread and process.
     5.    What are the components of linux operating system?
     6.    Briefly explain process creation.



                                                  PART B
          Each question carries 12 marks


    7.Describe the evolution of operating systems.
    8.Explain any four process scheduling algorithms with example
  9.Explain process management in detail.
   Answer key
1.-OS is an interface between hardware and user.(1)
-2 views-System view and user view(1)
Parts of a computer system&explanation of parts(2)




1.            Hardware – provides basic computing resources (CPU, memory, I/O devices).
2. Operating system – controls and coordinates the use of the hardware among the various application
   programs for the various users.

3. Applications programs – define the ways in which the system resources are used to solve the
   computing problems of the users (compilers, database systems, video games, business programs).

4. Users (people, machines, other computers).


2.Real time operating system
-A real time system has well defined fixed time constraints. Processing should be done within the
defined constraints(1)
-Hard and Soft real time system(1)
      Hard real-time(1)
    Guarantees critical task completion on time.
    Secondary storage limited or absent, data stored in short term memory, or read-only memory
     (ROM)
    Conflicts with time-sharing systems, not supported by general-purpose operating systems.
    Advanced OS features are absent (e.g. virtual memory is absent).
    Soft real-time(1)
    Less restrictive.
    A critical real time task gets priority over other tasks and it retains its priority until it completes.
    Limited utility in industrial control of robotics
3.Process states




                                                                                  (2)
   Five states are as follows (2)
    new: The process is being created
    running: Instructions are being executed
    waiting: The process is waiting for some event to occur
    ready: The process is waiting to be assigned to a processor
    terminated: The process has finished execution
4.Thread and process
     Thread is light weight. Process is heavy weight
     Thread occupy less memory. Process occupy more memory
     Process has so many thread but the reverse is not true
     Thread is a process but the reverse is not true

5.Components of linux OS

1.Kernel
          The kernel is responsible for maintaining the important abstractions of the operating
system.Kernel code executes in kernel mode with full access to all the physical resources of the
computer.All kernel code and data structures are kept in the same single address space.

2.System libraries

             The system libraries define a standard set of functions through which applications interact
with the kernel, and which implement much of the operating-system functionality that does not need
the full privileges of kernel code.


3.System utilities
       The system utilities perform individual specialized management tasks.




6.Process creation

-Using fork system call

-Parent process creates children processes, which, in turn create other processes, forming a tree of
processes.

-Resource sharing
Parent and children share all resources.
Children share subset of parent’s resources.
Parent and child share no resources.

-Execution
Parent and children execute concurrently.
Parent waits until children terminate.


7.Evolution of operating system


1.Batch OS
-Similar jobs are grouped into a batch
-Disadvantage:CPU will be idle,not interactive
2.Multiprogrammed OS
-Several jobs are kept in memory at the same time




Adv:CPU will be busy most of the time
Disadv:Not interactive
3.Timesharing OS
-The CPU is multiplexed among several jobs that are kept in memory and on disk (the CPU is allocated
to a job only if the job is in memory).

A job is swapped in and out of memory to the disk.

On-line communication between the user and the system is provided; when the operating system
finishes the execution of one command, it seeks the next “control statement” not from a card reader, but
rather from the user’s keyboard.

On-line system must be available for users to access data and code.

4.Real time OS
A real time system has well defined fixed time constraints. Processing should be done within the
defined constraints
-Hard and Soft real time system
      Hard real-time
    Guarantees critical task completion on time.
    Secondary storage limited or absent, data stored in short term memory, or read-only memory
     (ROM)
    Conflicts with time-sharing systems, not supported by general-purpose operating systems.
    Advanced OS features are absent (e.g. virtual memory is absent).
    Soft real-time
      Less restrictive.
      A critical real time task gets priority over other tasks and it retains its priority until it completes.
      Limited utility in industrial control of robotics

5.Multiprocessing OS


Multiprocessor systems with more than one CPU in close communication.

Tightly coupled system – processors share memory and a clock; communication usually takes place
through the shared memory.

Advantages of parallel system:
-Increased throughput
-Economical
-Increased reliability
Symmetric multiprocessing (SMP)
Each processor runs an identical copy of the operating system.
Many processes can run at once without performance deterioration.
Most modern operating systems support SMP

Asymmetric multiprocessing
Each processor is assigned a specific task; master processor schedules and allocates work to slave
processors.
More common in extremely large systems

6.Distributed OS


Distribute the computation among several physical processors.

Loosely coupled system – each processor has its own local memory; processors communicate with one
another through various communications lines, such as high-speed buses or telephone lines.

Advantages of distributed systems.
Resources Sharing
Computation speed up – load sharing
Reliability
Communications

8.Any 4 Scheduling algorithms
(I) First Come First Serve (FCFS)
     The process that request first for the processor is allotted the processor first.
      The ready queue is maintained as a FIFO queue.
      When the processor becomes free it is allotted to the process at the head of the queue and when
       a new process arrives it is entered at the tail of the queue.
It is the simplest algorithm and easy to implement.
(II) Shortest Job First Scheduling (SJF)
      Here among the processes in the ready queue, the one with the least CPU burst time will be
       allotted the processor first.
      If two processes have their burst time equal, then FCFS scheduling is used.
      The average waiting time is small when compared to FCFS scheduling.
      SJF is optimal algorithm.
      It is difficult to implement because knowing the length of the next CPU burst is difficult.
      SJF can be non preemptive or preemptive.
The preemptive version of SJF is called Shortest Remaining Time First scheduling. Here when a new
job arrives in the ready queue, its CPU burst is compared with the remaining CPU burst of the currently
running process. If the newly arrived process has got the smaller burst then the currently running
process will be preempted and the new process will be allotted to the processor. The preempted process
will enter the ready queue and wait for its turn to get the processor.


(III) Priority Scheduling
      Each process is assigned a priority number (integer).
      The CPU is allocated to the process with the highest priority (smallest integer may be
       considered as highest priority).
      Priority scheduling can be preemptive or non preemptive.
      In preemptive priority scheduling, while a process is executing, if a new process with high
       priority than the currently running process arrives, the process is preempted and the processor is
       allocated to the new process. SJF is a priority scheduling where priority is the predicted next
       CPU burst time.


The problem with priority scheduling is that a low priority processes may have to wait indefinitely to
get the processor to execute. This is called starvation. The solution is to increase the priority of the
process as time progresses. This is called aging.

       (IV) Round Robin Scheduling
      Each process gets a small amount of CPU time known as time quantum.
      When the time elapses process is preempted and the processor is allocated to the next process at
       the head of the ready queue.
      When the time quantum is very high this scheduling behaves as FCFS and when the time
       quantum is very small overhead will be high. It should be large with respect to context switch.
9.Process management

Process

   Process – a program in execution; process execution must progress in sequential fashion
   A process includes:
          o program counter
          o stack
          o data section
  Process states
    As a process executes, it changes state. The state of a process is defined in part by the current
      activity of that process.

   A two state process model

      Process may be in one of two states
          o Running
          o Not-running




Process Creation

 When a new process is to be added to those currently being managed, the OS builds DS that are used
to manage the process and allocates address space in main memory to the process. Processes are
created
     In batch environment, during the submission of a batch job
     In interactive environment, when user logs on
Process Termination
      Processes are terminated
     In batch systems, when job issues Halt instruction
     In interactive systems, User logs off
     When Quit an application
process control block (PCB)
A process is represented in the OS by a process control block (PCB)




      Process state: The state may be any one of the five discussed earlier.
      Program counter: Holds the address of the next instruction to be executed for the process.
      CPU registers: The registers may vary depending on the architecture. The registers should be
       saved if an interrupt occurs. This will help the process to continue correctly afterwards.
      CPU-scheduling information: This includes process priority, pointers to scheduling queues etc.
      Memory-management information: This includes the value of the base and limit registers and
       the page tables or segment tables.
      Accounting information: This includes the amount of CPU and real time used, time limits,
       process numbers etc.
      I/O status information: This includes the list of I/O devices allocated to the process, a list of
       open files etc.




Process scheduling

       It is to assign processes to be executed by the processor or processors over time.
   It is broken into 3 – long, medium and short term scheduling.

    (i) Long term Scheduling
                         It decides which programs are admitted to the system for processing.
         It controls the degree of multiprogramming
         More processes, smaller percentage of time each process is being executed.

   (ii) Medium term Scheduling
        It is part of the swapping function.
   (iii) Short term Scheduling
          Also known as CPU scheduler
           Selects which process should be executed next and allocates CPU




Context Switch
      Switching the CPU from one process to another is called context switch.

      It involves saving the state of the old process and loading the saved state of the new process.

      The state of a process includes the value of the CPU registers, the process state and memory
       management information. This information is saved in the PCB of the process.

      The processor does no useful work during this process, so the time for context switch is an
       overhead.

Scheduling Criteria
The different criteria used to compare the performance of the scheduling algorithms are the following:

      CPU Utilization: It is the percentage of time the CPU is kept busy.
      Throughput: It is the number of processes completed per unit time.
      Turnaround time: It is time from the submission of a job to the completion of the job. It is the
       sum of waiting time and time for which the process uses the CPU.
      Waiting time: It is the amount of time the process spends in the ready queue waiting for the
       processor.
      Response time: It is time from the submission of a job to the time the first response is
       obtained.
Scheduling algorithms
1.FCFS
2.SJF
3.Priority scheduling
4.Round robin scheduling
5.Multilevel queue scheduling
6.Multilevel feedback queue scheduling