Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Reg. No. SNS COLLEGE OF TECHNOLOGY A (An Autonomous Institution) INTERNAL ASSESSMENT EXAMINATION-I ACADEMIC YEAR 2016 – 17 (Even Semester) FOURTH SEMESTER B.E – COMPUTER SCIENCE AND ENGINEERING CS203– OPERATING SYSTEMS TIME: 1 Hour 30 Mins Maximum: 50 Marks PART – A (5 x 1 = 5 MARKS) ANSWER ALL QUESTIONS 1. Which of the following do not belong to queues for processes? a) Job Queue b) PCB Queue c) Device Queue d) Ready Queue 2. An IPC facility provides at least two operations 3. a) write message and read c) send message and receive A process can be 4. a) single threaded b) multithreaded c) both (a) and (b) d) none of the mentioned Semaphore is a/an _______ to solve the critical section problem. 5. a) hardware for a system b) special program for a system c) integer variable d) None of these The two atomic operations permissible on semaphores are a) wait b) stop and hold b) delete message d) read message c) signal d) Both a) and c) PART – B (5 x 2 = 10 MARKS) ANSWER ALL QUESTIONS 6. 7. 8. Define operating system. A collection of programs and utilities, it is the interface between user and computer. It creates the user friendly environment. Define resource allocation graph. A resource allocation graph is a graph used to represent the deadlock. It consisting of two symbols and edges. A square is used to represent resources and the circle is used to represent the process. An edge from a process to resource is called requesting edge. An edge from a resource to process is called the assignment edge. List the services of operating system Program execution 1 9. 10. Accounting Program execution Controlled access to files System access Error detection and response Access to I/O devices. Define process control block. The process control block, it is the central data structure in an operating system. Each process maintains one PCB. Each PCB contains all the information about a process that is needed by the operating system. List the three requirements that must satisfy by the critical-section problem. Mutual Exclusion Progress Bounded waiting PART – C (14 + 14 + 7 = 35 Marks) ANSWER ALL QUESTIONS 11. a) Define process. Explain states of process with neat sketch and discuss the process state transition with a neat diagram. A process is basically a program in execution. The execution of a process must progress in a sequential fashion. Process Life Cycle When a process executes, it passes through different states. These stages may differ in different operating systems, and the names of these states are also not standardized. In general, a process can have one of the following five states at a time. State & Description 1. Start: This is the initial state when a process is first started/created. 2. Ready: The process is waiting to be assigned to a processor. Ready processes are waiting to have the processor allocated to them by the operating system so that they can run. Process may come into this state after Start state or while running it by but interrupted by the scheduler to assign CPU to some other process. 3. Running: Once the process has been assigned to a processor by the OS scheduler, the process state is set to running and the processor executes its instructions. 2 (14 ) 4. Waiting: Process moves into the waiting state if it needs to wait for a resource, such as waiting for user input, or waiting for a file to become available. 5. Terminated or Exit: Once the process finishes its execution, or it is terminated by the operating system, it is moved to the terminated state where it waits to be removed from main memory. Process States Information associated with each process Process state – new ,ready, running, waiting, halted Program counter – address of the next instruction CPU registers – accumulators ,index registers, stack pointers CPU scheduling information – process priority, pointers to scheduling queues Memory-management information – base and limit registers, page tables, segment tables Accounting information – amount of CPU and real time used, time limits, account numbers, job or process numbers I/O status information –list of I/O devices , list of open files Process Control Block (PCB) CPU Switch From Process to Process b) OR Consider the following set of processes, with the length of the CPU-burst (14 ) time given in milliseconds: Process Burst Time Priority P1 10 3 P2 1 1 P3 2 3 P4 1 4 P5 5 2 The processes are arrived in the order P1, P2, P3, P4, P5, ALL AT TIME 0. (1) Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF, a non preemptive priority (a smaller priority number implies a higher priority), and RR (quantum=1) scheduling. 3 (2) What is the turnaround time and waiting time of each process for each of the scheduling algorithms in part a? (3) Which of the schedules in part a results in the minimal average waiting time (overall processes)? FCFS: WAITING TIME: 9.6, TURN AROUND TIME: 13.4 SJF: WAITING TIME: 9.6, TURN AROUND TIME: 7 PRIORITY: WAITING TIME: 9.6, TURN AROUND TIME: 5.2 ROUND ROBIN: WAITING TIME: 9.6, TURN AROUND TIME: 9 12. a) Describe the Inter Process communication in client-server systems. Mechanism for processes to communicate and to synchronize their actions Message system – processes communicate with each other without resorting to shared variables i) Message passing system IPC facility provides two operations: send(message) – message size fixed or variable receive(message) If P and Q wish to communicate, they need to: establish a communication link between them exchange messages via send/receive Implementation of communication link physical (e.g., shared memory, hardware bus) logical (e.g., logical properties) Implementation Questions How are links established? Can a link be associated with more than two processes? How many links can there be between every pair of communicating processes? What is the capacity of a link? Is the size of a message that the link can accommodate fixed or variable? Is a link unidirectional or bi-directional several methods of implementing a link -direct /indirect communication -symmetric/asymmetric communication -automatic /explicit buffering -send by copy/send by reference -fixed sized /variable sized msg ii) Naming A) Direct Communication Processes must name each other explicitly: send (P, message) – send a message to process P receive(Q, message) – receive a message from process Q 4 (14 ) Properties of communication link Links are established automatically A link is associated with exactly one pair of communicating processes Between each pair there exists exactly one link The link may be unidirectional, but is usually bi-directional B) Indirect Communication Messages are directed and received from mailboxes (also referred to as ports) Each mailbox has a unique id Processes can communicate only if they share a mailbox Properties of communication link Link established only if processes share a common mailbox A link may be associated with many processes Each pair of processes may share several communication links Link may be unidirectional or bi-directional Operations create a new mailbox send and receive messages through mailbox destroy a mailbox Primitives are defined as: send(A, message) – send a message to mailbox A receive(A, message) – receive a message from mailbox A Mailbox sharing P1, P2, and P3 share mailbox A P1, sends; P2 and P3 receive Who gets the message? Solutions Allow a link to be associated with at most two processes Allow only one process at a time to execute a receive operation Allow the system to select arbitrarily the receiver. Sender is notified who the receiver was. iii) Synchronization Message passing may be either blocking or non-blocking Blocking is considered synchronous Blocking send has the sender block until the message is received Blocking receive has the receiver block until a message is available Non-blocking is considered asynchronous Non-blocking send has the sender send the message and continue Non-blocking receive has the receiver receive a valid message or null iv) Buffering Queue of messages attached to the link; implemented in one of three ways 1. Zero capacity – 0 messages Sender must wait for receiver (rendezvous) 2. Bounded capacity – finite length of n messages Sender must wait if link full 3. Unbounded capacity – infinite length Sender never waits Client-Server Communication Sockets Remote Procedure Calls Remote Method Invocation (Java) 5 i) Sockets A socket is defined as an endpoint for communication pair of sockets – one for each process socket made up of Concatenation of IP address and port number The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8 Communication consists between a pair of sockets Socket Communication java provides 3 different types of sockets - connection oriented (TCP) - connection less(UDP) - multicast socket ii) Remote Procedure Calls Remote procedure call (RPC) abstracts procedure calls between processes on networked systems. Stubs – client-side proxy for the actual procedure on the server. The client-side stub locates the server and marshalls the parameters. The server-side stub receives this message, unpacks the marshalled parameters, and peforms the procedure on the server. Execution of RPC iii) Remote Method Invocation Remote Method Invocation (RMI) is a Java mechanism similar to RPCs. RMI allows a Java program on one machine to invoke a method on a remote object. the RMI implements the remote object using stubs and skeletons stub is a proxy for the remote object - it resides with the client client side stub is responsible for creating a parcel consisting the name of the method to be invoked on the server and the marshaled parameters for the method 6 the skeleton is responsible for unmarshalling the parameters and invoking the desired method on the server. Marshalling Parameters b) OR Consider the following Snapshot of a system. Allocation Max Available ABCD ABCD ABCD P0 0012 0012 1520 P1 1000 1750 P2 1354 2356 P3 0632 0652 P4 0014 0656 Answer the following questions using the banker’s algorithm. a. What is the content of the matrix Need? b. Is the system in a safe state? c. If a request from process P1 arrives for (0,4,2,0), can the request be (14 granted immediately? ) a)NEED MATRIX: 0 0 0 0 0 7 5 0 1 0 0 2 0 0 2 0 0 6 4 2 b) THE SYSTEM IS IN SAFE STATE: P0,P2,P3,P4,P1 c) YES THE REQUEST CAN BE GRANTED 13. a) Illustrate the various deadlock prevention methods. Restrain the ways request can be made. Mutual Exclusion – not required for sharable resources; must hold for nonsharable resources. Hold and Wait – must guarantee that whenever a process requests a resource, it does not hold any other resources. 7 (7) Require process to request and be allocated all its resources before it begins execution, or allow process to request resources only when the process has none. Low resource utilization; starvation possible. No Preemption – If a process that is holding some resources requests another resource that cannot be immediately allocated to it, then all resources currently being held are released. Preempted resources are added to the list of resources for which the process is waiting. Process will be restarted only when it can regain its old resources, as well as the new ones that it is requesting. Circular Wait – impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration. Deadlock Avoidance Requires that the system has some additional a priori information available. Simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need. The deadlock-avoidance algorithm dynamically examines the resourceallocation state to ensure that there can never be a circular-wait condition. Resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the processes. Safe State When a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state. System is in safe state if there exists a sequence <P1, P2, …, Pn> of ALL the processes is the systems such that for each Pi, the resources that Pi can still request can be satisfied by currently available resources + resources held by all the Pj, with j < i. That is: If Pi resource needs are not immediately available, then Pi can wait until all Pj have finished. When Pj is finished, Pi can obtain needed resources, execute, return allocated resources, and terminate. When Pi terminates, Pi +1 can obtain its needed resources, and so on. Basic Facts If a system is in safe state no deadlocks. If a system is in unsafe state possibility of deadlock. Avoidance ensure that a system will never enter an unsafe state Safe, Unsafe , Deadlock State 8 OR b) Explain in detail about reader writer problem A data set is shared among a number of concurrent processes • Readers – only read the data set; they do not perform any updates • Writers – can both read and write. Problem – allow multiple readers to read at the same time. Only one single writer can access the shared data at the same time. Shared Data • Data set • Semaphore mutex initialized to 1. • Semaphore wrt initialized to 1. Integer readcount initialized to 0. The structure of a writer process while (true) { wait (wrt) ; // writing is performed signal (wrt) ; } The structure of a reader process while (true) { wait (mutex) ; readcount ++ ; if (readcount == 1) wait (wrt) ; signal (mutex) // reading is performed wait (mutex) ; readcount - - ; if (readcount == 0) signal (wrt) ; signal (mutex) ; } prepared by verified by 9 HoD (7)