Sei sulla pagina 1di 7

Operating System

1. Define Operating System. Mention goals of OS and draw diagram of showing components of computer system. Operating System: A program running at all times on the computer that acts as an intermediary between a user of a computer and the computer hardware. It is a resource allocator that manages all resources and decides between conflicting requests for efficient and fair resource use. It is also a control program that controls execution of programs to prevent errors and improper use of the computer Operating system goals: 1. Execute user programs and make solving user problems easier 2. Make the computer system convenient to use. 3. Use the computer hardware in an efficient manner. Diagram showing components of computer system

2. Discuss the dual mode operation of operating system with neat diagram. Dual-mode operation allows OS to protect itself and other system components There are two modes that operating system works namely o User mode o kernel mode Mode bit is provided to switch between these two modes.

Mode bit: Provides ability to distinguish when system is running user code or kernel code Some instructions designated as privileged, only executable in kernel mode System call changes mode to kernel, return from call resets it to user
<<<<With little explanation>>>>

3. Explain common classes of services provided by operating systems for helping users and for efficient operation of system Operating system services can be divided into 1. Helpful to User a. User Interface b. Program execution c. File system manipulation d. Communication e. Error Detection 2. Helpful to System a. Resource allocation b. Accounting c. Protection and Security
<<<<Explain each in one or two sentences>>>>

4. Define Virtual Machine (VM). With neat diagram explain the working of VM. A virtual machine provides an interface identical to the underlying bare hardware. The operating system host creates the illusion that a process has its own processor and (virtual) memory. Each guest provided with a (virtual) copy of underlying computer. OR The fundamental idea behind a virtual machine is to abstract the hardware of a single computer (the CPU, memory, disk drives, network interface cards, and so forth) into

several different execution environments, thereby creating the illusion that each separate execution environment is running its own private computer.

5. Define the following a. Bootstrap loader b. System call c. Context switch d. Long term scheduler a. Bootstrap Loader: Small piece of code bootstrap loader, locates the kernel, loads it into memory, and starts it. Firmware used to hold initial boot code. When power initialized on system, execution starts at a fixed memory location. GRUB is an example of an open-source bootstrap program for Linux systems. b. System Call: System Call Provides interface to the services made available by the OS. This is the mechanism by which a program requests a service from an operating system's kernel. These are typically written in a high-level language (C or C++). Popular system calls are open, read, write, close, wait, exec, fork, exit, and kill. c. Context Switch: When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a context switch. Context of a process represented in the PCB. Context-switch time is purely overhead; the system does no useful work while switching Time taken to context switch dependents on hardware support. d. Long term scheduler: Long-term scheduler (or job scheduler) selects which processes should be brought into the ready queue i.e. it loads processes from disk to memory. Longterm scheduler is invoked very infrequently in terms of seconds or minutes. The longterm scheduler controls the degree of multiprogramming (number of processes in memory).

6. Define Process and explain the states of process with neat diagram. A process is an active entity, with a program counter specifying the next instruction to execute and a set of associated resources. A program becomes a process when an executable file is loaded into 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 (e.g., I/O completion) ready: The process is waiting to be assigned to a processor terminated: The process has finished execution

7. Discuss three common ways of establishing relationship between User thread and Kernel thread. There are two types of threads 1. User Level Threads, 2. Kernel Level Threads Ultimately, a relationship must exist between user threads and kernel threads There are three multithreading models Many-to-One One-to-One Many-to-Many Many-to-One Many user-level threads mapped to single kernel thread Examples: Solaris Green Threads, GNU Portable Threads

One-to-One Each user-level thread maps to kernel thread Examples o Windows NT/XP/2000 o Linux o Solaris 9 and later

Many-to-Many Allows many user level threads to be mapped to many kernel threads Allows the operating system to create a sufficient number of kernel threads Examples o Solaris prior to version 9 o Windows NT/2000 with the ThreadFiber package

8. Discuss about the threading issues during thread handling. There are several threading issues when handling threads The fork() and exec() System Calls Thread Cancellation Signal Handling Thread Pools Thread-Specific Data Scheduler Activations 1. The fork() and exec() System Calls: If one thread in a program calls fork(), does the new process duplicate all threads, or is the new process single-threaded? If a thread invokes the exec() system call, the program specified in the parameter to exec() will replace the entire processincluding all threads

2. Thread Cancellation Thread cancellation is the task of terminating a thread before it has completed There are two ways to terminate thread o Asynchronous cancellation. One thread immediately terminates the target thread. o Deferred cancellation. The target thread periodically checks whether it should terminate, allowing it an opportunity to terminate itself in an orderly fashion. The difficulty with cancellation occurs in situations where resources have been allocated to a canceled thread or where a thread is canceled while in the midst of updating data it is sharing with other threads Deferred cancellation is better way of cancelling a thread 3. Signal Handling Signals are used in UNIX systems to notify a process that a particular event has occurred. A signal handler is used to process signals o Signal is generated by particular event o Signal is delivered to a process o Signal is handled delivering signals is more complicated in multithreaded programs Options: o Deliver the signal to the thread to which the signal applies o Deliver the signal to every thread in the process o Deliver the signal to certain threads in the process o Assign a specific thread to receive all signals for the process 4. Thread Pools A number of threads at process startup and place them into a pool, where they sit and wait for work. When a server receives a request, it awakens a thread from this poolif one is availableand passes it the request for service. Once the thread completes its service, it returns to the pool and awaits more work. Thread pools offer these benefits: Servicing a request with an existing thread is usually faster than waiting to create a thread.

A thread pool limits the number of threads that exist at any one point. This is particularly important on systems that cannot support a large number of concurrent threads. 5. Thread Specific Data In some circumstances, each thread might need its own copy of certain data. We will call such data thread-specific data. Allows each thread to have its own copy of data Useful when you do not have control over the thread creation process (i.e., when using a thread pool) 6. Scheduler Activation One scheme for communication between the user-thread library and the kernel is known as scheduler activation. Working : The kernel provides an application with a set of virtual processors (LWPs), and the application can schedule user threads onto an available virtual processor. Furthermore, the kernel must inform an application about certain events.

Potrebbero piacerti anche