I HEREBY MAKE NO CLAIM THAT THE SAME QUESTIONS WILL BE
REPEATED OR ASKED IN THE INTERVIEW AND AS YOU DOWNLOAD THIS POWERPOINT SLIDES IT IS UNDERSTOOD THAT YOU ARE USING THESE SLIDES AT YOUR OWN RISK. FURTHER EVERY ATTEMPT HAS BEEN TAKEN TO ENSURE THAT THERE IS NO ERRATA IN THE DATA PROVIDED AND IF ANY FOUND IT IS UPTO YOU TO CORRECT IT. THIS IN NO WAY IS AN EXHAUSTIVE COLLECTION OF QUESTIONS.AS YOU DOWNLOAD THESE FILES IT IS UNDERSTOOD THAT YOU AGREE WITH ME. PLEASE MAIL ANY BUGS,REPORTS,SUGGESTIONS TO raghavarun@indiatimes.com
Operating System Operating System controls all the computers resources and provides the base upon which the application programs run.
The layer of software on top of the bare hardware, to manage all parts of the system, and present the user with an interface or virtual machine that is easier to understand and program.
Operating System Microprogram: The layer of software usually located in read-only memory.
Reduced Instruction Set Computers: The hardware executes the machine language instructions directly. Eg., IBM PowerPC
Kernel / Supervisor Mode: It is protected from user tampering the hardware.
User Mode Compilers and editors run in user mode. Operating System First Digital Computer Analytical Engine. Charles Babbage
Generations of OS: Vacuum Tubes and Plugboards (1945-55) Transistors and Batch Systems (1955-1965) IC s and Multiprogramming (1965-1980) PC s(1980 Present)
Operating System When a running job finished, the Operating System could load a new job from the disk into the now-empty portion and run it. This technique is called Spooling(Simultaneous Peripheral Operation On-Line).
Time Sharing and Multi programming: Its a variant of multi programming in which each user has an on line terminal. In a timesharing system, if 20 users are logged in and 17 of them are thinking the CPU is allocated in turn to the three jobs that want service.
POSIX: To make it possible to write programs that could run on any UNIX systems. A minimal system call interface that conformant UNIX Systems must support. Operating System System Calls : The interface between the Operating System and the user programs is defined by the set of extended instructions that the Operating System provides.
+ Process: + Program in execution. + Associated with each process is address space(executable program, the programs data and stack) , a list of memory locations.
+ Process Table: + All the info about each process is stored in a table, which is an array or linked lists one for each process. Operating System IPC: Related processes that are cooperating to get some job done often need to communicate with one another and synchronize their activities.
Signal: They are the software analog of hardware interrupts and can be generated by a variety of causes in addition to timers expiring.
Pipe : Sort of pseudofile that can be used to connect two processes together. Operating System SIGKILL (Signal 9)
Canonical Mode: Normal Terminal Mode, in which erase and kill characters work normally
Non canonical Mode : A minimum number of characters to accept and a time, specified in units of 1/10 of a s.
OS structure: Monolithic Systems: There is no structure. The OS is written as a collection of procedures, each of which can call any of the other ones whenever it needs to.
Operating System There is no information hiding in monolithic systems.
Layered Systems: OS as a hierarchy of layers, each one constructed upon the one below it. Eg, THE System Virtual Machine: Runs on the bare hardware and does the multiprogramming.
Process States: Running (actually using the CPU at that instant) Ready (runnable; temporarily stopped to let another process run). Blocked(unable to run until some external event happens) Operating System Interrupt Vector: It contains the address of the interrupt service procedure.
Threads(Light weight process): In modern OS, support is provided for multiple threads of control within a process.
(IPC)Race Conditions: When two or more processes are reading or writing some shared data and the final result depends on who runs precisely when, are called race conditions.
Critical Sections: Part of the process where the share memory is accessed. Operating System Producer Consumer problem:
#define N 100 Int count=0; Void producer(void) {while(TRUE) {produce_item(); If(count==N)sleep(); Enter_item(); Count++; If(count==1)wakeup(consumer); }}
Two processes share a common, fixed size buffer. One of them, the producer,puts information into the buffer, and the other one, the consumer, takes it out. Operating System Semaphore(E.W.Dijkstra,1965): - A new variable type, that has the value 0 when no wakeups were saved, or some positive value if one or more wakeups were pending.
- Atomic Action: - Checking the value, changing it, and possibly going to sleep is all done as a single, indivisible, atomic action.
Binary Semaphores: Semaphores that are initialized to 1 and used by two or more processes to ensure that only one of them can enter its critical region at the same time. Use of Semaphore: 1)Synchronization. 2)Mutual Exclusion Operating System Monitors : A collection of procedures, variables and data structures that are all grouped together in a package. Processes may call the procedures in a monitor whenever they want to, but they cannot directly access the monitors internal data structures from procedures declared outside the monitor.
(Classical IPC problems)Dining Philosophers problem: Starvation is deadlock. Used for modeling processes that are competing for exclusive access to a limited number of resources. Operating System @ Models access to a database. @ Eg., Airline Reservation System @ Having two readers at the same time is not a problem, the second reader is admitted. @ As long as atleast one reader is still active, susbsequent readers are admitted.
@ Correction: @ When a reader arrives and a writer is waiting, the reader is suspended behind the writer instead of being admitted immediately.
@ Disadvantages: @ Less concurrency @ Lower Performance Operating System Sleeping Barber Problem: + Three Semaphores: Customers, Barbers, mutex. + Customers counts waiting customers (excluding person in chair) + Barbers number of barbers who are idle + Mutex used for mutual exclusion + Waiting copy of customers
+ Customer enters the shop, counts the number of waiting customers. If it is less than the number of chairs, he stays; otherwise, he leaves.
Operating System Process Scheduling When more than one process is runnable, the Operating System must decide which one to run first. The part of the OS which does this is Scheduler. The algorithm it uses is called Scheduling algorithm.
Fairness make sure each process gets its fair share of the CPU Efficiency keep the CPU busy 100 percent of the time Response time minimize response time for interactive users. Turnaround minimize the time batch users must wait for output. Throughput maximize the number of jobs processed per hour. Operating System Preemptive Scheduling The strategy of allowing processes that are logically runnable to be temporarily suspended. Non preemptive Scheduling : Run to completion method.
Round Robin Scheduling Quantum(Each process is assigned a time interval) Priority Scheduling Multiple Queues Shortest Job First Guaranteed Scheduling Operating System Lottery Scheduling Real time Scheduling Two level scheduling Policy vs. mechanisms Operating System Deadlock : Two or more processes are blocked and will remain so forever. Can Occur on both Hardware and Software resources. Occur on Non preemptable resource.
Preemptable resource: Can be taken away from the process owning it with no ill effects. Eg., Memory
Non preemptable resource: Cannot be taken away from its current owner without causing the computation to fail. Eg., Printer. Operating System O Deadlock: O A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause.
O Conditions for Deadlock: O Condition - Approach O Mutual Exclusion Spool Everything O Hold and Wait - Request all resources initially O No preemption Take resources away O Circular wait Order resources numerically O All four of the conditions must be present for a deadlock to occur. Operating System DeadLock Avoidance: Bankers Algorithm:
Operating System Memory Manager: The part of the OS that manages the memory hierarchy
+ Swapping: + Bringing each process in its entirety, running it for a while, then putting it back on disk.
+ Virtual Memory: + Allows programs to run even when they are only partially in main memory.
+ Memory Compaction: + When swapping creates multiple holes in memory, it is possible to combine them all into one big one by moving all the processes downwards as far as possible. Operating System Virtual Memory: The combined size of the program, size and stack may exceed the amount of physical memory available for it.
Paging: Addresses can be generated using indexing, base registers, segment registers. Program generated addresses are called virtual addresses and form the virtual address space. The virtual address space is divided up into units called pages. The corresponding units in the physical memory is called page frames. The page number is used as an index into the page table, yielding the number of the page frame corresponding to that virtual page.
Operating System Translation look aside buffer: Device for mapping virtual addresses to physical addresses without going thru the page table.
- Inverted page table: There is one entry per page frame in real memory, rather than one entry per page of virtual address space.
- Page Replacement Algorithms: - Optimal Page Replacement - Not Recently used - FIFO - Second Chance - Clock page - LRU Operating System
Segments:
The virtual memory is one dimensional because the virtual addresses go from 0 to some maximum address, one address after another.
For many programs, two or more separate virtual address spaces may be better.One grows and one shrinks leading in unpredictable results.
Solution: provide the machine with many completely independent address spaces called segments. Different segments may have different lengths. Operating System Thrasing: A program causing page faults every few instructions is said to be thrashing.
Page Fault: Memory management unit notices that the page is unmapped, and causes the CPU to trap to the Operating System.