G. S. Mandal s MARATHWADA INSTITUTE OF TECHNOLOGY Affiliated to Dr. Babasaheb Ambedkar Marathwada Universtiy, Aurangabad. Department of Computer Science & Engineering Third Year Engineering Academic Year: 2017-18 (Semester-I) Course: Operating System (CSE 301) Q.1 a) Simple Batch Systems Model Answer Paper for Unit Test 1 Memory Layout for a Simple Batch System The first Batch OS was developed in the mid-1950s by General motors for use on IBM 701. Use of Monitor is the central idea. User no longer has direct access to the processor. User submits the job on cards or tape to a operator. Operator batches the jobs and places the batch on an input device, for use by the monitor. Reduce setup time by batching similar jobs Automatic job sequencing automatically transfers control from one job to another. First rudimentary operating system. Resident monitor
initial control in monitor control transfers to job when job completes control transfers back to monitor Advantage The Simple batch system improves utilization of the computer. Disadvantage Some main memory is now occupied by monitor. Some processor time is consumed by the monitor. Q.1 b) Ans Smart Card Operating Systems The smallest OS run on smart cards, containing a CPU chip. They have very severe processing power and memory constraints. They can handle a single function such as electronic payments. Often these are proprietary systems. Some are powered by contacts in the reader and some are inductively powered. Some smart cards are Java oriented. ROM holds an interpreter for the JVM. Java applets (small programs) are downloaded to the card and are interpreted by the JVM interpreter. Resource mgmt. and protection are an issue sometimes. Q.1 C) Ans Thread 1. Threads are used for small tasks 1. A program in execution is known as 2. Thread is a lightweight process 3. es are used for more heavyweight tasks 4. Threads within the same process share the same address space 3. Different processes do not. Q.1 D) Ans Race conditions are a result of uncontrolled access to shared data. A condition in which the value of a shared data item d s resulting from execution of operations ai and aj on ds in interacting processes may be different from both fi(fj(ds)) and fj(fi(ds)).
working together may share data, that may be in main memory or a share file. e.g. A print spooler When process wants to print a file, it enters a file name in spooler directory. Printer daemon process periodically checks directory for file name, which are to be printed. If available, print them and remove their names from directory. e.g. A spooler directory has many slots and 2 shared variable in & out Two variables are kept on a two word file available to all process. A reads in and stores its value in local variable next_free_slot which is 7. Clock interrupt occurred. B started running reads in=7, puts its file there and calculate new in=8 After some time A starts, already read value of in which is 7, update contexts at location 7 and calculates in=8. Situations like this, where two or more processes are reading or writing some shared data and the final result depends on who runs precisely when are called race condition. Q.2 Ans A request that a program makes to the kernel through a software interrupt. System calls is the interface users contact with OS and hardware. System calls vary from system to system, but the underlying concepts are similar. These calls are generally available as routines written in C and C++. Low level tasks may need to be written using assembly-language instructions.
Figure indicates steps in making the system call read(fd, buffer, nbytes).
Q.2 b) ANS 1. Monolithic Operating system structure is- A basic structure for the Operating system: 1. A main program that invokes the requested service procedure. 2. A set of service procedures that carry out the system calls. 3. A set of utility procedures that help the service procedures. For each system call, there is one service procedure that takes care of it and executes it. The utility procedures do things that are needed by several service procedures. Core OS is loaded when the computer is booted, extensions such as I/O device drivers and file systems are loaded on demand. Early operating systems had a monolithic structure. The entire OS runs as a single program in kernel mode. The OS is written as a collection of procedures, linked together into a single large executable binary program. Each procedure is free to call any other one. One first compiles all the individual procedures or files and then binds them all together into a single executable file using the system linker. The services provided by the OS are requested by putting the parameters in a welldefined place (e.g. stack) and then executing a trap instruction.
2. Layered Operating System structure Figure: - Structure of the THE operating system. It attacks the complexity and cost of developing and maintaining an OS. A routine situated in one layer does not know data structures or instructions in the lower layer. Information hiding also implies that an OS layer may be modified without affecting other layers. This structure simplify testing, debugging, modification of an OS. Three problems of layered design The operation of a system may be slowed down by the layered structure. Every layer must provide all features and facilities to above layer. This poses a problem in ordering of layers. The stratification of OS functionalities. A new functionality requires new code to be added in many layers of the OS which in turn may require changes in the layer interfaces. Layered strucuture does not guarantee high portability. Q.3 a) Ans A process is a program in execution. A program becomes a process when an executable file is loaded into memory. A process is an active entity. PC specifying the next instruction to execute and a set of associated resources. Two processes may be associated with the same program. Although the text sections are equivalent the data, heap and stack sections vary.
States: - Figure in memory
As a process executes, it changes state 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 process. terminated: The process has finished execution. Q.3 b) ANS B.T. P1 10 P2 1 P3 2 P4 1 P5 5 1. FCFS - P1 P2 P3 P4 P5 0 10 11 13 14 19 2. SJF - P2 P4 P3 P5 P1 0 1 2 4 9 19 FCFS: - TAT P1 10 P2 11 P3 13 P4 14 P5 19 SJF: - TAT P1 19 P2 1 P3 4 P4 2 P5 9
WT process FCFS SJF P1 0 9 P2 10 0 P3 11 2 P4 13 1 P5 14 4 Awt 9.6 3.2