Os question
Upcoming SlideShare
Loading in...5
×
 

Os question

on

  • 1,112 views

interview questions

interview questions

Statistics

Views

Total Views
1,112
Views on SlideShare
1,112
Embed Views
0

Actions

Likes
1
Downloads
81
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Os question Os question Document Transcript

  • 1. What is an operating system?Ans: An operating system is a program that acts as an intermediary between the user and thecomputer hardware. The purpose of an OS is to provide a convenient environment in which usercan execute programs in a convenient and efficient manner.It is a resource allocator responsiblefor allocating system resources and a control program which controls the operation of thecomputer h/w.2. What are the various components of a computer system?Ans:1. The hardware2. The operating system3. The application programs4. The users.3.What is purpose of different operating systems?Ans:The machine Purpose Workstation individual usability &Resources utilization MainframeOptimize utilization of hardware PC Support complex games, business application Hand heldPCs Easy interface & min. power consumption4.What are the different operating systems?Ans:1. Batched operating systems2. Multi-programmed operating systems3. timesharing operating systems4. Distributed operating systems5. Real-time operating systems6.What is a boot-strap program?7.What is BIOS?8.Explain the concept of the batched operating systems?Ans: In batched operating system the users gives their jobs to the operator who sorts theprograms according to their requirements and executes them. This is time consuming butmakes the CPU busy all the time.9.Explain the concept of the multi-programmed operating systems?Ans: A multi-programmed operating systems can execute a number of programs concurrently.The operating system fetches a group of programs from the job-pool in the secondary storagewhich contains all the programs to be executed, and places them in the main memory. Thisprocess is called job scheduling. Then it chooses aprogram from the ready queue and gives them to CPU to execute. When a executing programneeds some I/O operation then the operating system fetches another program and hands it tothe CPU for execution, thus keeping the CPU busy all the time.10.Explain the concept of the timesharing operating systems?Ans: It is a logical extension of the multi-programmed OS where user can interact with theprogram. The CPU executes multiple jobs by switching among them, but the switches occur sofrequently that the user feels as if the operating system is running only his program.
  • 11.Explain the concept of the multi-processor systems or parallel systems?Ans: They contain a no. of processors to increase the speed of execution, and reliability, andeconomy. They are of two types:1. Symmetric multiprocessing2. Asymmetric multiprocessingIn Symmetric multi processing each processor run an identical copy of the OS, and these copiescommunicate with each other as and when needed.But in Asymmetric multiprocessing eachprocessor is assigned a specific task.12.Explain the concept of the Distributed systems?Ans: Distributed systems work in a network. They can share the networkresources,communicate with each other13.Explain the concept of Real-time operating systems?Ans: A real time operating system is used when rigid time requirement have been placed on theoperation of a processor or the flow of the data; thus, it is often used as a control device in adedicated application. Here the sensors bring data to the computer. The computer must analyzethe data and possibly adjust controls tomodify the sensor input.They are of two types:1. Hard real time OS2. Soft real time OSHard-real-time OS has well-defined fixed time constraints. But soft real time operating systemshave less stringent timing constraints.14.Define MULTICS?Ans: MULTICS (Multiplexed information and computing services) operating system wasdeveloped from 1965-1970 at Massachusetts institute of technology as a computing utility.Many of the ideas used in MULTICS were subsequently used in UNIX.15.What is SCSI?Ans: Small computer systems interface.16.What is a sector?Ans: Smallest addressable portion of a disk.17.What is cache-coherency?Ans: In a multiprocessor system there exist several caches each may containing a copy ofsame variable A. Then a change in one cache should immediately be reflected in all othercaches this process of maintaining the same value of a data in all the caches s called cache-coherency.18.What are residence monitors?Ans: Early operating systems were called residence monitors.19.What is dual-mode operation?Ans: In order to protect the operating systems and the system programs from themalfunctioning programs the two mode operations were evolved:1. System mode.2. User mode.
  • Here the user programs cannot directly interact with the system resources, instead they requestthe operating system which checks the request and does the required task for the userprograms-DOS was written for / intel 8088 and has no dual-mode. Pentium provides dual-modeoperation.20.What are the operating system components?Ans:1. Process management2. Main memory management3. File management4. I/O system management5. Secondary storage management6. Networking7. Protection system8. Command interpreter system21.What are operating system services?Ans:1. Program execution2. I/O operations3. File system manipulation4. Communication5. Error detection6. Resource allocation7. Accounting8. Protection22.What are system calls?Ans: System calls provide the interface between a process and the operating system. Systemcalls for modern Microsoft windows platforms are part of the win32 API, which is available for allthe compilers written for Microsoft windows.23.What is a layered approach and what is its advantage?Ans: Layered approach is a step towards modularizing of the system, in which the operatingsystem is broken up into a number of layers (or levels), each built on top of lower layer. Thebottom layer is the hard ware and the top most is the user interface.The main advantage of thelayered approach is modularity. The layers areselected such that each uses the functions (operations) and services of only lower layer. Thisapproach simplifies the debugging and system verification.24.What is micro kernel approach and site its advantages?Ans: Micro kernel approach is a step towards modularizing the operating system where allnonessential components from the kernel are removed and implemented as system and userlevel program, making the kernel smaller.The benefits of the micro kernel approach include theease of extending the operating system. All new services are added to the user space andconsequently do not require modification of the kernel. And as kernel is smaller it is easier toupgrade it. Also this approach provides more security and reliability since most services arerunning as user processes rather than kernel’s keeping the kernel intact.
  • 25.What are a virtual machines and site their advantages?Ans: It is the concept by which an operating system can create an illusion that a process has itsown processor with its own (virtual) memory. The operating system implements virtual machineconcept by using CPU scheduling and virtual memory.1. The basic advantage is it provides robust level of security as each virtual machine is isolatedfrom all other VM. Hence the system resources are completely protected.2. Another advantage is that system development can be done without disrupting normaloperation. System programmers are given their own virtual machine, and as systemdevelopment is done on the virtual machine instead of on the actualphysical machine.3. Another advantage of the virtual machine is it solves the compatibility problem.EX: Java supplied by Sun micro system provides a specification for java virtual machine.26.What is a process?Ans: A program in execution is called a process. Or it may also be called a unit of work. Aprocess needs some system resources as CPU time, memory, files, and i/o devices toaccomplish the task. Each process is represented in the operating system by a process controlblock or task control block (PCB).Processes are of two types:1. Operating system processes2. User processes27.What are the states of a process?Ans:1. New2. Running3. Waiting4. Ready5. Terminated28.What are various scheduling queues?Ans:1. Job queue2. Ready queue3. Device queue29.What is a job queue?Ans: When a process enters the system it is placed in the job queue.30.What is a ready queue?Ans: The processes that are residing in the main memory and are ready and waiting to executeare kept on a list called the ready queue.31.What is a device queue?Ans: A list of processes waiting for a particular I/O device is called device queue.32.What is a long term scheduler & short term schedulers?Ans: Long term schedulers are the job schedulers that select processes from the job queue and
  • load them into memory for execution. The short term schedulers are the CPU schedulers thatselect a process form the ready queue and allocate the CPU to one of them.33.What is context switching?Ans: Transferring the control from one process to other process requires saving the state of theold process and loading the saved state for new process. This task is known as contextswitching.34.What are the disadvantages of context switching?Ans: Time taken for switching from one process to other is pure over head. Because the systemdoes no useful work while switching. So one of the solutions is to go for threading when everpossible.35.What are co-operating processes?Ans: The processes which share system resources as data among each other. Also theprocesses can communicate with each other via interprocess communication facility generallyused in distributed systems. The best example is chat program used on the www.36.What is a thread?Ans: A thread is a program line under execution. Thread sometimes called a light-weightprocess, is a basic unit of CPU utilization; it comprises a thread id, a program counter, a registerset, and a stack.37.What are the benefits of multithreaded programming?Ans:1. Responsiveness (needn’t to wait for a lengthy process)2. Resources sharing3. Economy (Context switching between threads is easy)4. Utilization of multiprocessor architectures (perfect utilization of the multiple processors).38.What are types of threads?Ans:1. User thread2. Kernel threadUser threads are easy to create and use but the disadvantage is that if they perform a blockingsystem calls the kernel is engaged completely to the single user thread blocking otherprocesses. They are created in user space.Kernel threads are supported directly by theoperating system. They are slower to create and manage. Most of the OS like Windows NT,Windows 2000, Solaris2, BeOS, and Tru64 Unix support kernel threading.39.Which category the java thread do fall in?Ans: Java threads are created and managed by the java virtual machine, they do not easily fallunder the category of either user or kernel thread……40.What are multithreading models?Ans: Many OS provide both kernel threading and user threading. They are called multithreadingmodels. They are of three types:1. Many-to-one model (many user level thread and one kernel thread).2. One-to-one model3. Many-to –many
  • In the first model only one user can access the kernel thread by not allowing multi-processing.Example: Green threads of Solaris.The second model allows multiple threads to run on parallelprocessing systems. Creating user thread needs to create corresponding kernel thread(disadvantage).Example: Windows NT, Windows 2000, OS/2.The third model allows the user tocreate as many threads as necessary and the corresponding kernel threads can run in parallelon a multiprocessor.Example: Solaris2, IRIX, HP-UX, and Tru64 Unix.41.What is a P-thread?Ans: P-thread refers to the POSIX standard (IEEE 1003.1c) defining an API for thread creationand synchronization. This is a specification for thread behavior, not an implementation. Thewindows OS have generally not supported the P-threads.42.What are java threads?Ans: Java is one of the small number of languages that support at the language level for thecreation and management of threads. However, because threads are managed by the javavirtual machine (JVM), not by a user-level library or kernel, it is difficult to classify Java threadsas either user- or kernel-level.43.What is process synchronization?Ans: A situation, where several processes access and manipulate the same data concurrentlyand the outcome of the execution depends on the particular order in which the access takesplace, is called race condition. To guard against the race condition we need to ensure that onlyone process at a time can be manipulatingthe same data. The technique we use for this is called process synchronization.44.What is critical section problem?Ans: Critical section is the code segment of a process in which the process may be changingcommon variables, updating tables, writing a file and so on. Only one process is allowed to gointo critical section at any given time (mutually exclusive).The critical section problem is todesign a protocol that the processes can use toco-operate. The three basic requirements of critical section are:1. Mutual exclusion2. Progress3. bounded waitingBakery algorithm is one of the solutions to CS problem.45.What is a semaphore?Ans: It is a synchronization tool used to solve complex critical section problems. A semaphoreis an integer variable that, apart from initialization, is accessed only through two standard atomicoperations: Wait and Signal.46.What is bounded-buffer problem?Ans: Here we assume that a pool consists of n buffers, each capable of holding one item. Thesemaphore provides mutual exclusion for accesses to the buffer pool and is initialized to thevalue 1.The empty and full semaphores count the number of empty and full buffers,respectively. Empty is initialized to n, and full is initialized to 0.47.What is readers-writers problem?Ans: Here we divide the processes into two types:
  • 1. Readers (Who want to retrieve the data only)2. Writers (Who want to retrieve as well as manipulate)We can provide permission to a number of readers to read same data at same time.But a writermust be exclusively allowed to access. There are two solutions to this problem:1. No reader will be kept waiting unless a writer has already obtained permission to use theshared object. In other words, no reader should wait for other readers to complete simplybecause a writer is waiting.2. Once a writer is ready, that writer performs its write as soon as possible. In other words, if awriter is waiting to access the object, no new may start reading.48.What is dining philosophers’ problem?Ans: Consider 5 philosophers who spend their lives thinking and eating. The philosophersshare a common circular table surrounded by 5 chairs, each belonging to one philosopher. Inthe center of the table is a bowl of rice, and the table is laid with five single chop sticks. When aphilosopher thinks, she doesn’t interact with her colleagues.From time to time, a philosopher gets hungry and tries to pick up two chop sticks that areclosest to her .A philosopher may pick up only one chop stick at a time. Obviously she can’t pickthe stick in some others hand. When a hungry philosopher has both her chopsticks at the sametime, she eats without releasing her chopsticks. When she is finished eating, she puts downboth of her chopsticks and start thinking again.49.What is a deadlock?Ans: Suppose a process request resources; if the resources are not available at that time theprocess enters into a wait state. A waiting process may never again change state, because theresources they have requested are held by some other waiting processes. This situation iscalled deadlock.50.What are necessary conditions for dead lock?Ans:1. Mutual exclusion (where at least one resource is non-sharable)2. Hold and wait (where a process hold one resource and waits for other resource)3. No preemption (where the resources can’t be preempted)4. circular wait (where p[i] is waiting for p[j] to release a resource. i= 1,2,…nj=if (i!=n) then i+1else 1 )51.What is resource allocation graph?Ans: This is the graphical description of deadlocks. This graph consists of a set of edges E anda set of vertices V. The set of vertices V is partitioned into two different types of nodesP={p1,p2,…,pn}, the set consisting of all the resources in the system, R={r1,r2,…rn}.A directededge Pi?Rj is called a request edge; a directed edge Rj?Pi is called an assignment edge. Pictorially we represent a process Pi as a circle, and eachresource type Rj as square.Since resource type Rj may have more than one instance, werepresent each such instance as a dot within the square.When a request is fulfilled the requestedge is transformed into an assignment edge. When a process releases a resource theassignment edge is deleted. If the cycle involves a set of resource types, each of which has onlya single instance, then a deadlock has occurred. Each process involved in the cycle is deadlock.
  • 52.What are deadlock prevention techniques?Ans:1. Mutual exclusion : Some resources such as read only files shouldn’t be mutuallyexclusive. They should be sharable. But some resources such as printers must bemutually exclusive.2. Hold and wait : To avoid this condition we have to ensure that if a process isrequesting for a resource it should not hold any resources.3. No preemption : If a process is holding some resources and requests anotherresource that cannot be immediately allocated to it (that is the process must wait),then all the resources currently being held are preempted(released autonomously).4. Circular wait : the way to ensure that this condition never holds is to impose atotal ordering of all the resource types, and to require that each process requestsresources in an increasing order of enumeration.53.What is a safe state and a safe sequence?Ans: A system is in safe state only if there exists a safe sequence. A sequence of processes isa safe sequence for the current allocation state if, for each Pi, the resources that the Pi can stillrequest can be satisfied by the currently available resources plus the resources held by all thePj, with j54.What are the deadlock avoidance algorithms?Ans: A dead lock avoidance algorithm dynamically examines the resource-allocation state toensure that a circular wait condition can never exist. The resource allocation state is defined bythe number of available and allocated resources, and the maximum demand of theprocess.There are two algorithms:1. Resource allocation graph algorithm2. Banker’s algorithma. Safety algorithmb. Resource request algorithm55. What are the basic functions of an operating system?Ans : Operating system controls and coordinates the use of the hardware among the variousapplications programs for various uses. Operating system acts as resource allocator andmanager. Since there are many possibly conflicting requests for resources the operating systemmust decide which requests are allocated resources to operating the computer systemefficiently and fairly. Also operating system is control program which controls the user programsto prevent errors and improper use of the computer. It is especially concerned with the operationand control of I/O devices.56.Explain briefly about, processor, assembler, compiler, loader, linker and the functionsexecuted by them.Ans :Processor:–A processor is the part a computer system that executes instructions .It is alsocalled a CPUAssembler: — An assembler is a program that takes basic computer instructions and convertsthem into a pattern of bits that the computer’s processor can use to perform its basic operations.Some people call these instructions assembler language and others use the term assemblylanguage.
  • Compiler: — A compiler is a special program that processes statements written in a particularprogramming language and turns them into machine language or “code” that a computer’sprocessor uses. Typically, a programmer writes language statements in a language such asPascal or C one line at a time using an editor. The file that is created contains what are calledthe source statements. The programmer then runs the appropriate language compiler,specifying the name of the file that contains the source statements.Loader:–In a computer operating system, a loader is a component that locates a given program(which can be an application or, in some cases, part of the operating system itself) in offlinestorage (such as a hard disk), loads it into main storage (in a personal computer, it’s calledrandom access memory), and gives that program control of the computeLinker: — Linker performs the linking of libraries with the object code to make the object codeinto an executable machine code.57. What is a Real-Time System?Ans : A real time process is a process that must respond to the events within a certain timeperiod. A real time operating system is an operating system that can run real time processessuccessfully58. What is the difference between Hard and Soft real-time systems?Ans : A hard real-time system guarantees that critical tasks complete on time. This goalrequires that all delays in the system be bounded from the retrieval of the stored data to the timethat it takes the operating system to finish any request made of it. A soft real time system wherea critical real-time task gets priority over other tasks and retains that priority until it completes.As in hard real time systems kernel delays need to be bounded59. What is virtual memory?Ans : A virtual memory is hardware technique where the system appears to have more memorythat it actually does. This is done by time-sharing, the physical memory and storage parts of thememory one disk when they are not actively being used60. What is cache memory?Ans : Cache memory is random access memory (RAM) that a computer microprocessor canaccess more quickly than it can access regular RAM. As the microprocessor processes data, itlooks first in the cache memory and if it finds the data there (from a previous reading of data), itdoes not have to do the more time-consuming reading of data61.Differentiate between Complier and Interpreter?Ans : An interpreter reads one instruction at a time and carries out the actions implied by thatinstruction. It does not perform any translation. But a compiler translates the entire instructions.62.What are different tasks of Lexical Analysis?Ans : The purpose of the lexical analyzer is to partition the input text, delivering a sequence ofcomments and basic symbols. Comments are character sequences to be ignored, while basicsymbols are character sequences that correspond to terminal symbols of the grammar definingthe phrase structure of the input63. Why paging is used?Ans : Paging is solution to external fragmentation problem which is to permit the logical address
  • space of a process to be noncontiguous, thus allowing a process to be allocating physicalmemory wherever the latter is available.64. What is Context Switch?Ans : Switching the CPU to another process requires saving the state of the old process andloading the saved state for the new process. This task is known as a context switch.Context-switch time is pure overhead, because the system does no useful work while switching. Itsspeed varies from machine to machine, depending on the memory speed, the number ofregisters which must be copied, the existed of special instructions(such as a single instruction toload or store all registers).65. Distributed Systems?Ans : Distribute the computation among several physical processors.Loosely coupled system – each processor has its own local memory; processors communicatewith one another through various communications lines, such as high-speed buses or telephonelinesAdvantages of distributed systems:->Resources Sharing->Computation speed up – load sharing->Reliability->Communications66.Difference between Primary storage and secondary storage?Ans :Main memory: – only large storage media that the CPU can access directly.Secondary storage: – extension of main memory that provides large nonvolatile storagecapacity.67. What is CPU Scheduler?Ans :->Selects from among the processes in memory that are ready to execute, and allocates theCPU to one of them.->CPU scheduling decisions may take place when a process:1.Switches from running to waiting state.2.Switches from running to ready state.3.Switches from waiting to ready.4.Terminates.->Scheduling under 1 and 4 is nonpreemptive.->All other scheduling is preemptive.68. What do you mean by deadlock?Ans : Deadlock is a situation where a group of processes are all blocked and none of them canbecome unblocked until one of the other becomes unblocked.The simplest deadlock is twoprocesses each of which is waiting for a message from the other69. What is Dispatcher?Ans :->Dispatcher module gives control of the CPU to the process selected by the short-termscheduler; this involves:Switching context
  • Switching to user modeJumping to the proper location in the user program to restart that programDispatch latency – time it takes for the dispatcher to stop one process and start another running.70. What is Throughput, Turnaround time, waiting time and Response time?Ans :Throughput – number of processes that complete their execution per time unitTurnaround time – amount of time to execute a particular processWaiting time – amount of time a process has been waiting in the ready queueResponse time – amount of time it takes from when a request was submitted until the firstresponse is produced, not output (for time-sharing environment)71. Explain the difference between microkernel and macro kernel?Ans :Micro-Kernel: A micro-kernel is a minimal operating system that performs only theessential functions of an operating system. All other operating system functions are performedby system processes.Monolithic: A monolithic operating system is one where all operating system code is in a singleexecutable image and all operating system code runs in system mode.72.What is multi tasking, multi programming, multi threading?Ans :Multi programming: Multiprogramming is the technique of running several programs at a timeusing timesharing.It allows a computer to do several things at the same time. Multiprogrammingcreates logical parallelism.The concept of multiprogramming is that the operating system keeps several jobs in memorysimultaneously. The operating system selects a job from the job pool and starts executing a job,when that job needs to wait for any i/o operations the CPU is switched to another job. So themain idea here is that the CPU is never idle.Multi tasking: Multitasking is the logical extension of multiprogramming .The concept ofmultitasking is quite similar to multiprogramming but difference is that the switching betweenjobs occurs so frequently that the users can interact with each program while it is running. Thisconcept is also known as time-sharing systems. A time-shared operating system uses CPUscheduling and multiprogramming to provide each user with a small portion of time-sharedsystem.Multi threading: An application typically is implemented as a separate process with severalthreads of control. In some situations a single application may be required to perform severalsimilar tasks for example a web server accepts client requests for web pages, images, sound,and so forth. A busy web server may have several of clients concurrently accessing it. If the webserver ran as a traditional single-threaded process, it would be able to service only one client ata time. The amount of time that a client might have to wait for its request to be serviced could beenormous.So it is efficient to have one process that contains multiple threads to serve the same purpose.This approach would multithread the web-server process, the server would create a separatethread that would listen for client requests when a request was made rather than creatinganother process it would create another thread to service the request.So to get the advantages like responsiveness, Resource sharing economy and utilization ofmultiprocessor architectures multithreading concept can be used
  • 73. Give a non-computer example of preemptive and non-preemptive scheduling?Ans : Consider any system where people use some kind of resources and compete for them.The non-computer examples for preemptive scheduling the traffic on the single lane road ifthere is emergency or there is an ambulance on the road the other vehicles give path to thevehicles that are in need. The example for preemptive scheduling is people standing in queuefor tickets.74. What is starvation and aging?Ans :Starvation: Starvation is a resource management problem where a process does not get theresources it needs for a long time because the resources are being allocated to otherprocesses.Aging: Aging is a technique to avoid starvation in a scheduling system. It works by adding anaging factor to the priority of each request. The aging factor must increase the request’s priorityas time passes and must ensure that a request will eventually be the highest priority request(after it has waited long enough)75.Different types of Real-Time Scheduling?Ans :Hard real-time systems – required to complete a critical task within a guaranteed amountof time.Soft real-time computing – requires that critical processes receive priority over less fortunateones.76. What are the Methods for Handling Deadlocks?Ans :->Ensure that the system will never enter a deadlock state.->Allow the system to enter a deadlock state and then recover.->Ignore the problem and pretend that deadlocks never occur in the system; used by mostoperating systems, includingUNIX.77. What is a Safe State and its’ use in deadlock avoidance?Ans :When a process requests an available resource, system must decide if immediateallocation leaves the system in a safe state->System is in safe state if there exists a safe sequence of all processes.->Sequence is safe if for each Pi, the resources that Pi can still request can be satisfied bycurrently available resources + resources held by all the Pj, with jIf 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, andterminate.When Pi terminates, Pi+1 can obtain its needed resources, and so on.->Deadlock Avoidance Þ ensure that a system will never enter an unsafe state.78. Recovery from Deadlock?Ans :Process Termination:->Abort all deadlocked processes.->Abort one process at a time until the deadlock cycle is eliminated.->In which order should we choose to abort?Priority of the process.How long process has computed, and how much longer to completion.
  • Resources the process has used.Resources process needs to complete.How many processes will need to be terminated?Is process interactive or batch?Resource Preemption:->Selecting a victim – minimize cost.->Rollback – return to some safe state, restart process for that state.->Starvation – same process may always be picked as victim, include number of rollback in costfactor.79.Difference between Logical and Physical Address Space?Ans :->The concept of a logical address space that is bound to a separate physical address space iscentral to proper memory management.Logical address – generated by the CPU; also referred to as virtual address.Physical address – address seen by the memory unit.->Logical and physical addresses are the same in compile-time and load-time address-bindingschemes; logical (virtual) and physical addresses differ in execution-time address-bindingscheme80. Binding of Instructions and Data to Memory?Ans :Address binding of instructions and data to memory addresses can happen at threedifferent stagesCompile time: If memory location known a priori, absolute code can be generated; mustrecompile code if starting location changes.Load time: Must generate relocatable code if memory location is not known at compile time.Execution time: Binding delayed until run time if the process can be moved during its executionfrom one memory segment to another. Need hardware support for address maps (e.g., baseand limit registers).81. What is Memory-Management Unit (MMU)?Ans :Hardware device that maps virtual to physical address.In MMU scheme, the value in the relocation register is added to every address generated by auser process at the time it is sent to memory.->The user program deals with logical addresses; it never sees the real physical addresses82. What are Dynamic Loading, Dynamic Linking and Overlays?Ans :Dynamic Loading:->Routine is not loaded until it is called->Better memory-space utilization; unused routine is never loaded.->Useful when large amounts of code are needed to handle infrequently occurring cases.->No special support from the operating system is required implemented through programdesign.Dynamic Linking:->Linking postponed until execution time.->Small piece of code, stub, used to locate the appropriate memory-resident library routine.->Stub replaces itself with the address of the routine, and executes the routine.
  • ->Operating system needed to check if routine is in processes’ memory address.->Dynamic linking is particularly useful for libraries.Overlays:->Keep in memory only those instructions and data that are needed at any given time.->Needed when process is larger than amount of memory allocated to it.->Implemented by user, no special support needed from operating system, programming designof overlay structure is complex.83. What is fragmentation? Different types of fragmentation?Ans : Fragmentation occurs in a dynamic memory allocation system when many of the freeblocks are too small to satisfy any request.External Fragmentation: External Fragmentation happens when a dynamic memory allocationalgorithm allocates some memory and a small piece is left over that cannot be effectively used.If too much external fragmentation occurs, the amount of usable memory is drasticallyreduced.Total memory space exists to satisfy a request, but it is not contiguousInternal Fragmentation: Internal fragmentation is the space wasted inside of allocated memoryblocks because of restriction on the allowed sizes of allocated blocks.Allocated memory may beslightly larger than requested memory; this size difference is memory internal to a partition, butnot being used Reduce external fragmentation by compaction->Shuffle memory contents to place all free memory together in one large block.->Compaction is possible only if relocation is dynamic, and is done at execution time.84. Define Demand Paging, Page fault interrupt, and Trashing?Ans :Demand Paging: Demand paging is the paging policy that a page is not read into memory untilit is requested, that is, until there is a page fault on the page.Page fault interrupt: A page fault interrupt occurs when a memory reference is made to a pagethat is not in memory.The present bit in the page table entry will be found to be off by the virtualmemory hardware and it will signal an interrupt.Trashing: The problem of many page faults occurring in a short time, called “page thrashing,”85. Explain Segmentation with paging?Ans : Segments can be of different lengths, so it is harder to find a place for a segment inmemory than a page. With segmented virtual memory, we get the benefits of virtual memory butwe still have to do dynamic storage allocation of physical memory. In order to avoid this, it ispossible to combine segmentation and paging into a two-level virtual memory system. Eachsegment descriptor points to page table for that segment.This give some of the advantages ofpaging (easy placement) with some of the advantages of segments (logical division of theprogram).86. Under what circumstances do page faults occur? Describe the actions taken by theoperating system when a page fault occurs?Ans : A page fault occurs when an access to a page that has not been brought into mainmemory takes place. The operating system verifies the memory access, aborting the program ifit is invalid. If it is valid, a free frame is located and I/O is requested to read the needed pageinto the free frame. Upon completion of I/O, the process table and page table are updated andthe instruction is restarted87. What is the cause of thrashing? How does the system detect thrashing? Once itdetects thrashing, what can the system do to eliminate this problem?
  • Ans : Thrashing is caused by under allocation of the minimum number of pages required by aprocess, forcing it to continuously page fault. The system can detect thrashing by evaluating thelevel of CPU utilization as compared to the level of multiprogramming. It can be eliminated byreducing the level of multiprogramming.51.What is resource allocation graph?Ans: This is the graphical description of deadlocks. This graph consists of a set of edges E anda set of vertices V. The set of vertices V is partitioned into two different types of nodesP={p1,p2,…,pn}, the set consisting of all the resources in the system, R={r1,r2,…rn}.A directededge Pi?Rj is called a request edge; a directed edge Rj?Pi is called an assignment edge. Pictorially we represent a process Pi as a circle, and eachresource type Rj as square.Since resource type Rj may have more than one instance, werepresent each such instance as a dot within the square.When a request is fulfilled the requestedge is transformed into an assignment edge. When a process releases a resource theassignment edge is deleted. If the cycle involves a set of resource types, each of which has onlya single instance, then a deadlock has occurred. Each process involved in the cycle is deadlock.52.What are deadlock prevention techniques?Ans:1. Mutual exclusion : Some resources such as read only files shouldn’t be mutuallyexclusive. They should be sharable. But some resources such as printers must bemutually exclusive.2. Hold and wait : To avoid this condition we have to ensure that if a process isrequesting for a resource it should not hold any resources.3. No preemption : If a process is holding some resources and requests anotherresource that cannot be immediately allocated to it (that is the process must wait),then all the resources currently being held are preempted(released autonomously).4. Circular wait : the way to ensure that this condition never holds is to impose atotal ordering of all the resource types, and to require that each process requestsresources in an increasing order of enumeration.53.What is a safe state and a safe sequence?Ans: A system is in safe state only if there exists a safe sequence. A sequence of processes isa safe sequence for the current allocation state if, for each Pi, the resources that the Pi can stillrequest can be satisfied by the currently available resources plus the resources held by all thePj, with j54.What are the deadlock avoidance algorithms?Ans: A dead lock avoidance algorithm dynamically examines the resource-allocation state toensure that a circular wait condition can never exist. The resource allocation state is defined bythe number of available and allocated resources, and the maximum demand of theprocess.There are two algorithms:1. Resource allocation graph algorithm2. Banker’s algorithma. Safety algorithmb. Resource request algorithm
  • 55. What are the basic functions of an operating system?Ans : Operating system controls and coordinates the use of the hardware among the variousapplications programs for various uses. Operating system acts as resource allocator andmanager. Since there are many possibly conflicting requests for resources the operating systemmust decide which requests are allocated resources to operating the computer systemefficiently and fairly. Also operating system is control program which controls the user programsto prevent errors and improper use of the computer. It is especially concerned with the operationand control of I/O devices.56.Explain briefly about, processor, assembler, compiler, loader, linker and the functionsexecuted by them.Ans :Processor:–A processor is the part a computer system that executes instructions .It is alsocalled a CPUAssembler: — An assembler is a program that takes basic computer instructions and convertsthem into a pattern of bits that the computer’s processor can use to perform its basic operations.Some people call these instructions assembler language and others use the term assemblylanguage.Compiler: — A compiler is a special program that processes statements written in a particularprogramming language and turns them into machine language or “code” that a computer’sprocessor uses. Typically, a programmer writes language statements in a language such asPascal or C one line at a time using an editor. The file that is created contains what are calledthe source statements. The programmer then runs the appropriate language compiler,specifying the name of the file that contains the source statements.Loader:–In a computer operating system, a loader is a component that locates a given program(which can be an application or, in some cases, part of the operating system itself) in offlinestorage (such as a hard disk), loads it into main storage (in a personal computer, it’s calledrandom access memory), and gives that program control of the computeLinker: — Linker performs the linking of libraries with the object code to make the object codeinto an executable machine code.57. What is a Real-Time System?Ans : A real time process is a process that must respond to the events within a certain timeperiod. A real time operating system is an operating system that can run real time processessuccessfully58. What is the difference between Hard and Soft real-time systems?Ans : A hard real-time system guarantees that critical tasks complete on time. This goalrequires that all delays in the system be bounded from the retrieval of the stored data to the timethat it takes the operating system to finish any request made of it. A soft real time system wherea critical real-time task gets priority over other tasks and retains that priority until it completes.As in hard real time systems kernel delays need to be bounded59. What is virtual memory?Ans : A virtual memory is hardware technique where the system appears to have more memorythat it actually does. This is done by time-sharing, the physical memory and storage parts of thememory one disk when they are not actively being used60. What is cache memory?Ans : Cache memory is random access memory (RAM) that a computer microprocessor can
  • access more quickly than it can access regular RAM. As the microprocessor processes data, itlooks first in the cache memory and if it finds the data there (from a previous reading of data), itdoes not have to do the more time-consuming reading of data61.Differentiate between Complier and Interpreter?Ans : An interpreter reads one instruction at a time and carries out the actions implied by thatinstruction. It does not perform any translation. But a compiler translates the entire instructions.62.What are different tasks of Lexical Analysis?Ans : The purpose of the lexical analyzer is to partition the input text, delivering a sequence ofcomments and basic symbols. Comments are character sequences to be ignored, while basicsymbols are character sequences that correspond to terminal symbols of the grammar definingthe phrase structure of the input63. Why paging is used?Ans : Paging is solution to external fragmentation problem which is to permit the logical addressspace of a process to be noncontiguous, thus allowing a process to be allocating physicalmemory wherever the latter is available.64. What is Context Switch?Ans : Switching the CPU to another process requires saving the state of the old process andloading the saved state for the new process. This task is known as a context switch.Context-switch time is pure overhead, because the system does no useful work while switching. Itsspeed varies from machine to machine, depending on the memory speed, the number ofregisters which must be copied, the existed of special instructions(such as a single instruction toload or store all registers).65. Distributed Systems?Ans : Distribute the computation among several physical processors.Loosely coupled system – each processor has its own local memory; processors communicatewith one another through various communications lines, such as high-speed buses or telephonelinesAdvantages of distributed systems:->Resources Sharing->Computation speed up – load sharing->Reliability->Communications66.Difference between Primary storage and secondary storage?Ans :Main memory: – only large storage media that the CPU can access directly.Secondary storage: – extension of main memory that provides large nonvolatile storagecapacity.67. What is CPU Scheduler?Ans :->Selects from among the processes in memory that are ready to execute, and allocates theCPU to one of them.->CPU scheduling decisions may take place when a process:
  • 1.Switches from running to waiting state.2.Switches from running to ready state.3.Switches from waiting to ready.4.Terminates.->Scheduling under 1 and 4 is nonpreemptive.->All other scheduling is preemptive.68. What do you mean by deadlock?Ans : Deadlock is a situation where a group of processes are all blocked and none of them canbecome unblocked until one of the other becomes unblocked.The simplest deadlock is twoprocesses each of which is waiting for a message from the other69. What is Dispatcher?Ans :->Dispatcher module gives control of the CPU to the process selected by the short-termscheduler; this involves:Switching contextSwitching to user modeJumping to the proper location in the user program to restart that programDispatch latency – time it takes for the dispatcher to stop one process and start another running.70. What is Throughput, Turnaround time, waiting time and Response time?Ans :Throughput – number of processes that complete their execution per time unitTurnaround time – amount of time to execute a particular processWaiting time – amount of time a process has been waiting in the ready queueResponse time – amount of time it takes from when a request was submitted until the firstresponse is produced, not output (for time-sharing environment)71. Explain the difference between microkernel and macro kernel?Ans :Micro-Kernel: A micro-kernel is a minimal operating system that performs only theessential functions of an operating system. All other operating system functions are performedby system processes.Monolithic: A monolithic operating system is one where all operating system code is in a singleexecutable image and all operating system code runs in system mode.72.What is multi tasking, multi programming, multi threading?Ans :Multi programming: Multiprogramming is the technique of running several programs at a timeusing timesharing.It allows a computer to do several things at the same time. Multiprogrammingcreates logical parallelism.The concept of multiprogramming is that the operating system keeps several jobs in memorysimultaneously. The operating system selects a job from the job pool and starts executing a job,when that job needs to wait for any i/o operations the CPU is switched to another job. So themain idea here is that the CPU is never idle.Multi tasking: Multitasking is the logical extension of multiprogramming .The concept ofmultitasking is quite similar to multiprogramming but difference is that the switching between
  • jobs occurs so frequently that the users can interact with each program while it is running. Thisconcept is also known as time-sharing systems. A time-shared operating system uses CPUscheduling and multiprogramming to provide each user with a small portion of time-sharedsystem.Multi threading: An application typically is implemented as a separate process with severalthreads of control. In some situations a single application may be required to perform severalsimilar tasks for example a web server accepts client requests for web pages, images, sound,and so forth. A busy web server may have several of clients concurrently accessing it. If the webserver ran as a traditional single-threaded process, it would be able to service only one client ata time. The amount of time that a client might have to wait for its request to be serviced could beenormous.So it is efficient to have one process that contains multiple threads to serve the same purpose.This approach would multithread the web-server process, the server would create a separatethread that would listen for client requests when a request was made rather than creatinganother process it would create another thread to service the request.So to get the advantages like responsiveness, Resource sharing economy and utilization ofmultiprocessor architectures multithreading concept can be used73. Give a non-computer example of preemptive and non-preemptive scheduling?Ans : Consider any system where people use some kind of resources and compete for them.The non-computer examples for preemptive scheduling the traffic on the single lane road ifthere is emergency or there is an ambulance on the road the other vehicles give path to thevehicles that are in need. The example for preemptive scheduling is people standing in queuefor tickets.74. What is starvation and aging?Ans :Starvation: Starvation is a resource management problem where a process does not get theresources it needs for a long time because the resources are being allocated to otherprocesses.Aging: Aging is a technique to avoid starvation in a scheduling system. It works by adding anaging factor to the priority of each request. The aging factor must increase the request’s priorityas time passes and must ensure that a request will eventually be the highest priority request(after it has waited long enough)75.Different types of Real-Time Scheduling?Ans :Hard real-time systems – required to complete a critical task within a guaranteed amountof time.Soft real-time computing – requires that critical processes receive priority over less fortunateones.76. What are the Methods for Handling Deadlocks?Ans :->Ensure that the system will never enter a deadlock state.->Allow the system to enter a deadlock state and then recover.->Ignore the problem and pretend that deadlocks never occur in the system; used by mostoperating systems, includingUNIX.
  • 77. What is a Safe State and its’ use in deadlock avoidance?Ans :When a process requests an available resource, system must decide if immediateallocation leaves the system in a safe state->System is in safe state if there exists a safe sequence of all processes.->Sequence is safe if for each Pi, the resources that Pi can still request can be satisfied bycurrently available resources + resources held by all the Pj, with jIf 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, andterminate.When Pi terminates, Pi+1 can obtain its needed resources, and so on.->Deadlock Avoidance Þ ensure that a system will never enter an unsafe state.78. Recovery from Deadlock?Ans :Process Termination:->Abort all deadlocked processes.->Abort one process at a time until the deadlock cycle is eliminated.->In which order should we choose to abort?Priority of the process.How long process has computed, and how much longer to completion.Resources the process has used.Resources process needs to complete.How many processes will need to be terminated?Is process interactive or batch?Resource Preemption:->Selecting a victim – minimize cost.->Rollback – return to some safe state, restart process for that state.->Starvation – same process may always be picked as victim, include number of rollback in costfactor.79.Difference between Logical and Physical Address Space?Ans :->The concept of a logical address space that is bound to a separate physical address space iscentral to proper memory management.Logical address – generated by the CPU; also referred to as virtual address.Physical address – address seen by the memory unit.->Logical and physical addresses are the same in compile-time and load-time address-bindingschemes; logical (virtual) and physical addresses differ in execution-time address-bindingscheme80. Binding of Instructions and Data to Memory?Ans :Address binding of instructions and data to memory addresses can happen at threedifferent stagesCompile time: If memory location known a priori, absolute code can be generated; mustrecompile code if starting location changes.Load time: Must generate relocatable code if memory location is not known at compile time.Execution time: Binding delayed until run time if the process can be moved during its executionfrom one memory segment to another. Need hardware support for address maps (e.g., baseand limit registers).
  • 81. What is Memory-Management Unit (MMU)?Ans :Hardware device that maps virtual to physical address.In MMU scheme, the value in the relocation register is added to every address generated by auser process at the time it is sent to memory.->The user program deals with logical addresses; it never sees the real physical addresses82. What are Dynamic Loading, Dynamic Linking and Overlays?Ans :Dynamic Loading:->Routine is not loaded until it is called->Better memory-space utilization; unused routine is never loaded.->Useful when large amounts of code are needed to handle infrequently occurring cases.->No special support from the operating system is required implemented through programdesign.Dynamic Linking:->Linking postponed until execution time.->Small piece of code, stub, used to locate the appropriate memory-resident library routine.->Stub replaces itself with the address of the routine, and executes the routine.->Operating system needed to check if routine is in processes’ memory address.->Dynamic linking is particularly useful for libraries.Overlays:->Keep in memory only those instructions and data that are needed at any given time.->Needed when process is larger than amount of memory allocated to it.->Implemented by user, no special support needed from operating system, programming designof overlay structure is complex.83. What is fragmentation? Different types of fragmentation?Ans : Fragmentation occurs in a dynamic memory allocation system when many of the freeblocks are too small to satisfy any request.External Fragmentation: External Fragmentation happens when a dynamic memory allocationalgorithm allocates some memory and a small piece is left over that cannot be effectively used.If too much external fragmentation occurs, the amount of usable memory is drasticallyreduced.Total memory space exists to satisfy a request, but it is not contiguousInternal Fragmentation: Internal fragmentation is the space wasted inside of allocated memoryblocks because of restriction on the allowed sizes of allocated blocks.Allocated memory may beslightly larger than requested memory; this size difference is memory internal to a partition, butnot being used Reduce external fragmentation by compaction->Shuffle memory contents to place all free memory together in one large block.->Compaction is possible only if relocation is dynamic, and is done at execution time.84. Define Demand Paging, Page fault interrupt, and Trashing?Ans :Demand Paging: Demand paging is the paging policy that a page is not read into memory untilit is requested, that is, until there is a page fault on the page.Page fault interrupt: A page fault interrupt occurs when a memory reference is made to a pagethat is not in memory.The present bit in the page table entry will be found to be off by the virtualmemory hardware and it will signal an interrupt.Trashing: The problem of many page faults occurring in a short time, called “page thrashing,”
  • 85. Explain Segmentation with paging?Ans : Segments can be of different lengths, so it is harder to find a place for a segment inmemory than a page. With segmented virtual memory, we get the benefits of virtual memory butwe still have to do dynamic storage allocation of physical memory. In order to avoid this, it ispossible to combine segmentation and paging into a two-level virtual memory system. Eachsegment descriptor points to page table for that segment.This give some of the advantages ofpaging (easy placement) with some of the advantages of segments (logical division of theprogram).86. Under what circumstances do page faults occur? Describe the actions taken by theoperating system when a page fault occurs?Ans : A page fault occurs when an access to a page that has not been brought into mainmemory takes place. The operating system verifies the memory access, aborting the program ifit is invalid. If it is valid, a free frame is located and I/O is requested to read the needed pageinto the free frame. Upon completion of I/O, the process table and page table are updated andthe instruction is restarted87. What is the cause of thrashing? How does the system detect thrashing? Once itdetects thrashing, what can the system do to eliminate this problem?Ans : Thrashing is caused by under allocation of the minimum number of pages required by aprocess, forcing it to continuously page fault. The system can detect thrashing by evaluating thelevel of CPU utilization as compared to the level of multiprogramming. It can be eliminated byreducing the level of multiprogramming.
  • UNIX1. How are devices represented in UNIX?Ans: All devices are represented by files called special files that are located in/dev directory.Thus, device files and other files are named and accessed in the same way. A ‘regular file’ isjust an ordinary data file in the disk. A ‘block special file’ represents a device with characteristicssimilar to a disk (data transfer in terms of blocks). A ‘character special file’ represents a devicewith characteristics similar to a keyboard (data transfer is by stream of bits in sequential order).2. What is ‘inode’?Ans: All UNIX files have its description stored in a structure called ‘inode’. The inode containsinfo about the file-size, its location, time of last access, time of last modification, permission andso on. Directories are also represented as files and have an associated inode. In addition todescriptions about the file, the inode contains pointers to the data blocks of the file. If the file islarge, inode has indirect pointer to a block of pointers to additional data blocks (this furtheraggregates for larger files). A block is typically 8k.Inode consists of the following fields:File owner identifierFile typeFile access permissionsFile access timesNumber of linksFile sizeLocation of the file data3. Brief about the directory representation in UNIX?Ans: A Unix directory is a file containing a correspondence between filenames and inodes. Adirectory is a special file that the kernel maintains. Only kernel modifies directories, butprocesses can read directories. The contents of a directory are a list of filename and inodenumber pairs. When new directories are created, kernel makes two entries named ‘.’ (refers tothe directory itself) and ‘..’ (refers to parent directory).System call for creating directory is mkdir (pathname, mode).4. What are the Unix system calls for I/O?Ans: open(pathname,flag,mode) – open filecreat(pathname,mode) – create fileclose(filedes) – close an open fileread(filedes,buffer,bytes) – read data from an open filewrite(filedes,buffer,bytes) – write data to an open filelseek(filedes,offset,from) – position an open file
  • dup(filedes) – duplicate an existing file descriptordup2(oldfd,newfd) – duplicate to a desired file descriptorfcntl(filedes,cmd,arg) – change properties of an open fileioctl(filedes,request,arg) – change the behaviour of an open fileThe difference between fcntl anf ioctl is that the former is intended for any open file, while thelatter is for device-specific operations.5. How do you change File Access Permissions?Ans: Every file has following attributes:owner’s user ID ( 16 bit integer )owner’s group ID ( 16 bit integer )File access mode word‘r w x -r w x- r w x’(user permission-group permission-others permission)r-read, w-write, x-executeTo change the access mode, we use chmod(filename,mode).Example 1:To change mode of myfile to ‘rw-rw-r–’ (ie. read, write permission for user – read,writepermission for group – only read permission for others) we give the args as:chmod(myfile,0664) .Each operation is represented by discrete values‘r’ is 4‘w’ is 2‘x’ is 1Therefore, for ‘rw’ the value is 6(4+2).Example 2:To change mode of myfile to ‘rwxr–r–’ we give the args as:chmod(myfile,0744).6. What are links and symbolic links in UNIX file system?Ans: A link is a second name (not a file) for a file. Links can be used to assign more than onename to a file, but cannot be used to assign a directory more than one name or link filenameson different computers.Symbolic link ‘is’ a file that only contains the name of another file.Operation on the symbolic linkis directed to the file pointed by the it.Both the limitations of links are eliminated in symboliclinks.Commands for linking files are:Link ln filename1 filename2Symbolic link ln -s filename1 filename27. What is a FIFO?Ans: FIFO are otherwise called as ‘named pipes’. FIFO (first-in-first-out) is a special file which issaid to be data transient. Once data is read from named pipe, it cannot be read again. Also,data can be read only in the order written. It is used in interprocess communication where aprocess writes to one end of the pipe (producer) and the other reads from the other end(consumer).
  • 8. How do you create special files like named pipes and device files?Ans: The system call mknod creates special files in the following sequence.1. kernel assigns new inode,2. sets the file type to indicate that the file is a pipe, directory or special file,3. If it is a device file, it makes the other entries like major, minor device numbers.For example:If the device is a disk, major device number refers to the disk controller and minor devicenumber is the disk.9. Discuss the mount and unmount system calls ?Ans : The privileged mount system call is used to attach a file system to a directory of anotherfile system; the unmount system call detaches a file system. When you mount another filesystem on to your directory, you are essentially splicing one directory tree onto a branch inanother directory tree. The first argument to mount call is the mount point, that is , a directory inthe current file naming system. The second argument is the file system to mount to that point.When you insert a cdrom to your unix system’s drive, the file system in the cdrom automaticallymounts to /dev/cdrom in your system.10. How does the inode map to data block of a file?Ans: Inode has 13 block addresses. The first 10 are direct block addresses of the first 10 datablocks in the file. The 11th address points to a one-level index block. The 12th address points toa two-level (double in-direction) index block. The 13th address points to a three-level(triple in-direction)index block. This provides a very large maximum file size with efficient access to largefiles, but also small files are accessed directly in one disk read.11. What is a shell?Ans: A shell is an interactive user interface to an operating system services that allows an userto enter commands as character strings or through a graphical user interface. The shellconverts them to system calls to the OS or forks off a process to execute the command. Systemcall results and other information from the OS are presented to the user through an interactiveinterface. Commonly used shells are sh,csh,ks etc.12. Brief about the initial process sequence while the system boots up?Ans: While booting, special process called the ‘swapper’ or ‘scheduler’ is created with Process-ID 0. The swapper manages memory allocation for processes and influences CPU allocation.The swapper inturn creates 3 children:the process dispatcher, vhand and dbflush with IDs 1,2 and 3 respectively.This is done by executing the file /etc/init. Process dispatcher gives birth to the shell. Unix keepstrack of all the processes in an internal data structure called the Process Table (listing commandis ps -el).13. What are various IDs associated with a process?Ans: Unix identifies each process with a unique integer called ProcessID. The process thatexecutes the request for creation of a process is called the ‘parent process’ whose PID is‘Parent Process ID’. Every process is associated with a particular user called the ‘owner’ whohas privileges over the process. The identification for the user is ‘UserID’. Owner is the userwho executes the process. Process also has ‘Effective User ID’ which determines the accessprivileges for accessing resources like files.getpid() -process idgetppid() -parent process id
  • getuid() -user idgeteuid() -effective user id14. Explain fork() system call?Ans: The `fork()’ used to create a new process from an existing process. The new process iscalled the child process, and the existing process is called the parent. We can tell which iswhich by checking the return value from `fork()’. The parent gets the child’s pid returned to him,but the child gets 0 returned to him.15. Predict the output of the following program codemain(){fork();printf(“Hello World!”);}Ans: Hello World!Hello World!Explanation:The fork creates a child that is a duplicate of the parent process. The child begins from thefork().All the statements after the call to fork() will be executed twice.(once by the parentprocess and other by child). The statement before fork() is executed only by the parent process.16. Predict the output of the following program codemain(){fork(); fork(); fork();printf(“Hello World!”);}Ans: “Hello World” will be printed 8 times.Explanation:2^n times where n is the number of calls to fork()17. List the system calls used for process management:Ans: System calls Descriptionfork() To create a new processexec() To execute a new program in a processwait() To wait until a created process completes its executionexit() To exit from a process executiongetpid() To get a process identifier of the current processgetppid() To get parent process identifiernice() To bias the existing priority of a processbrk() To increase/decrease the data segment size of a process18. How can you get/set an environment variable from a program?Ans: Getting the value of an environment variable is done by using `getenv()’. Setting the valueof an environment variable is done by using `putenv()’.19. How can a parent and child process communicate?Ans: A parent and child can communicate through any of the normal inter-process
  • communication schemes (pipes, sockets, message queues, shared memory), but also havesome special ways to communicate that take advantage of their relationship as a parent andchild. One of the most obvious is that the parent can get the exit status of the child.20. What is a zombie?Ans: When a program forks and the child finishes before the parent, the kernel still keeps someof its information about the child in case the parent might need it – for example, the parent mayneed to check the child’s exit status. To be able to get this information, the parent calls `wait()’;In the interval between the child terminating and the parent calling `wait()’, the child is said to bea `zombie’ (If you do `ps’, the child will have a `Z’ in its status field to indicate this.)21. What are the process states in Unix?Ans: As a process executes it changes state according to its circumstances. Unix processeshave the following states:Running : The process is either running or it is ready to run .Waiting : The process is waiting for an event or for a resource.Stopped : The process has been stopped, usually by receiving a signal.Zombie : The process is dead but have not been removed from the process table.22. What Happens when you execute a program?Ans: When you execute a program on your UNIX system, the system creates a specialenvironment for that program. This environment contains everything needed for the system torun the program as if no other program were running on the system. Each process has processcontext, which is everything that is unique about the state of the program you are currentlyrunning. Every time you execute a program the UNIX system does a fork, which performs aseries of operations to create a process context and then execute your program in that context.The steps include the following:Allocate a slot in the process table, a list of currently running programs kept by UNIX.Assign a unique process identifier (PID) to the process.iCopy the context of the parent, the process that requested the spawning of the new process.Return the new PID to the parent process. This enables the parent process to examine orcontrol the process directly. After the fork is complete, UNIX runs your program.23. What Happens when you execute a command?Ans: When you enter ‘ls’ command to look at the contents of your current working directory,UNIX does a series of things to create an environment for ls and the run it: The shell has UNIXperform a fork. This creates a new process that the shell will use to run the ls program. Theshell has UNIX perform an exec of the ls program. This replaces the shell program and datawith the program and data for ls and then starts running that new program. The ls program isloaded into the new process context, replacing the text and data of the shell. The ls programperforms its task, listing the contents of the current directory.24. What is a Daemon?Ans: A daemon is a process that detaches itself from the terminal and runs, disconnected, inthe background, waiting for requests and responding to them. It can also be defined as thebackground process that does not belong to a terminal session. Many system functions arecommonly performed by daemons, including the sendmail daemon, which handles mail, and theNNTP daemon, which handles USENET news. Many other daemons may exist. Some of themost common daemons are:init: Takes over the basic running of the system when the kernel has finished the boot process.
  • inetd: Responsible for starting network services that do not have their own stand-alonedaemons. For example, inetd usually takes care of incoming rlogin, telnet, and ftp connections.cron: Responsible for running repetitive tasks on a regular schedule.25. What is ‘ps’ command for?Ans: The ps command prints the process status for some or all of the running processes. Theinformation given are the process identification number (PID),the amount of time that theprocess has taken to execute so far etc.26. How would you kill a process?Ans: The kill command takes the PID as one argument; this identifies which process toterminate. The PID of a process can be got using ‘ps’ command.27. What is an advantage of executing a process in background?Ans: The most common reason to put a process in the background is to allow you to dosomething else interactively without waiting for the process to complete. At the end of thecommand you add the special background symbol, &. This symbol tells your shell to execute thegiven command in the background.Example: cp *.* ../backup& (cp is for copy)28. How do you execute one program from within another?Ans: The system calls used for low-level process creation are execlp() and execvp(). Theexeclp call overlays the existing program with the new one , runs that and exits. The originalprogram gets back control only when an error occurs. execlp(path,file_name,arguments..); //lastargument must be NULL A variant of execlp called execvp is used when the number ofarguments is not known in advance. execvp(path,argument_array); //argument array should beterminated by NULL29. What is IPC? What are the various schemes available?Ans: The term IPC (Inter-Process Communication) describes various ways by which differentprocess running on some operating system communicate between each other. Variousschemes available are as follows: Pipes:One-way communication scheme through which different process can communicate. Theproblem is that the two processes should have a common ancestor (parent-child relationship).However this problem was fixed with the introduction of named-pipes (FIFO).Message Queues :Message queues can be used between related and unrelated processes running on a machine.Shared Memory:This is the fastest of all IPC schemes. The memory to be shared is mapped into the addressspace of the processes (that are sharing). The speed achieved is attributed to the fact that thereis no kernel involvement. But this scheme needs synchronization.Various forms of synchronization are mutexes, condition-variables, read-write locks, record-locks, and semaphores.30. What is the difference between Swapping and Paging?Ans: Swapping: Whole process is moved from the swap device to the main memory forexecution. Process size must be less than or equal to the available main memory. It is easier toimplementation and overhead to the system. Swapping systems does not handle the memory
  • more flexibly as compared to the paging systems.Paging:Only the required memory pages are moved to main memory from the swap device forexecution. Process size does not matter. Gives the concept of the virtual memory.It provides greater flexibility in mapping the virtual address space into the physical memory ofthe machine. Allows more number of processes to fit in the main memory simultaneously.Allows the greater process size than the available physical memory. Demand paging systemshandle the memory more flexibly.31. What is major difference between the Historic Unix and the new BSD release of UnixSystem V in terms of Memory Management?Ans: Historic Unix uses Swapping – entire process is transferred to the main memory from theswap device, whereas the Unix System V uses Demand Paging – only the part of the process ismoved to the main memory. Historic Unix uses one Swap Device and Unix System V allowmultiple Swap Devices.32. What is the main goal of the Memory Management?Ans: It decides which process should reside in the main memory, Manages the parts of thevirtual address space of a process which is non-core resident, Monitors the available mainmemory and periodically write the processes into the swap device to provide more processes fitin the main memory simultaneously.33. What is a Map?Ans: A Map is an Array, which contains the addresses of the free space in the swap device thatare allocatable resources, and the number of the resource units available there.This allows First-Fit allocation of contiguous blocks of a resource. Initially the Map contains oneentry – address (block offset from the starting of the swap area) and the total number ofresources. Kernel treats each unit of Map as a group of disk blocks. On the allocation andfreeing of the resources Kernel updates the Map for accurate information.34. What scheme does the Kernel in Unix System V follow while choosing a swap deviceamong the multiple swap devices?Ans: Kernel follows Round Robin scheme choosing a swap device among the multiple swapdevices in Unix System V.35. What is a Region?Ans: A Region is a continuous area of a process’s address space (such as text, data andstack). The kernel in a ‘Region Table’ that is local to the process maintains region. Regions aresharable among the process.36. What are the events done by the Kernel after a process is being swapped out from themain memory?Ans: When Kernel swaps the process out of the primary memory, it performs the following:Kernel decrements the Reference Count of each region of the process. If the reference countbecomes zero, swaps the region out of the main memory,Kernel allocates the space for theswapping process in the swap device,Kernel locks the other swapping process while the currentswapping operation is going on,The Kernel saves the swap address of the region in the regiontable.
  • 37. Is the Process before and after the swap are the same? Give reason.Ans: Process before swapping is residing in the primary memory in its original form. Theregions (text, data and stack) may not be occupied fully by the process, there may be few emptyslots in any of the regions and while swapping Kernel do not bother about the empty slots whileswapping the process out. After swapping the process resides in the swap (secondary memory)device. The regions swapped out will be present but only the occupied region slots but not theempty slots that were present before assigning. While swapping the process once again into themain memory, the Kernel referring to the Process Memory Map, it assigns the main memoryaccordingly taking care of the empty slots in the regions.38. What do you mean by u-area (user area) or u-block?Ans: This contains the private data that is manipulated only by the Kernel. This is local to theProcess, i.e. each process is allocated a u-area.39. What are the entities that are swapped out of the main memory while swapping theprocess out of the main memory?Ans: All memory space occupied by the process, process’s u-area, and Kernel stack areswapped out, theoretically. Practically, if the process’s u-area contains the Address TranslationTables for the process then Kernel implementations do not swap the u-area.40. What is Fork swap?Ans: fork() is a system call to create a child process. When the parent process calls fork()system call, the child process is created and if there is short of memory then the child process issent to the read-to-run state in the swap device, and return to the user state without swappingthe parent process. When the memory will be available the child process will be swapped intothe main memory.41. What is Expansion swap?Ans: At the time when any process requires more memory than it is currently allocated, theKernel performs Expansion swap. To do this Kernel reserves enough space in the swap device.Then the address translation mapping is adjusted for the new virtual address space but thephysical memory is not allocated. At last Kernel swaps the process into the assigned space inthe swap device. Later when the Kernel swaps the process into the main memory this assignsmemory according to the new address translation mapping.42. How the Swapper works?Ans: The swapper is the only process that swaps the processes. The Swapper operates only inthe Kernel mode and it does not uses System calls instead it uses internal Kernel functions forswapping. It is the archetype of all kernel process.43. What are the processes that are not bothered by the swapper? Give Reason.Ans: Zombie process: They do not take any up physical memory.Processes locked in memoriesthat are updating the region of the process.Kernel swaps only the sleeping processes ratherthan the ‘ready-to-run’ processes, as they have the higher probability of being scheduled thanthe Sleeping processes.44. What are the requirements for a swapper to work?Ans: The swapper works on the highest scheduling priority. Firstly it will look for any sleepingprocess, if not found then it will look for the ready-to-run process for swapping. But the majorrequirement for the swapper to work the ready-to-run process must be core-resident for at least
  • 2 seconds before swapping out. And for swapping in the process must have been resided in theswap device for at least 2 seconds. If the requirement is not satisfied then the swapper will gointo the wait state on that event and it is awaken once in a second by the Kernel.45. What are the criteria for choosing a process for swapping into memory from the swapdevice?Ans: The resident time of the processes in the swap device, the priority of the processes andthe amount of time the processes had been swapped out.46. What are the criteria for choosing a process for swapping out of the memory to theswap device?Ans: The process’s memory resident time,Priority of the process and the nice value.47. What do you mean by nice value?Ans: Nice value is the value that controls {increments or decrements} the priority of the process.This value that is returned by the nice () system call. The equation for using nice value is:Priority = (“recent CPU usage”/constant) + (base- priority) + (nice value) Only the administratorcan supply the nice value. The nice () system call works for the running process only. Nice valueof one process cannot affect the nice value of the other process.48. What are conditions on which deadlock can occur while swapping the processes?Ans: All processes in the main memory are asleep.All ‘ready-to-run’ processes are swappedout.There is no space in the swap device for the new incoming process that are swapped out of themain memory. There is no space in the main memory for the new incoming process.49. What are conditions for a machine to support Demand Paging?Ans: Memory architecture must based on Pages, The machine must support the ‘restartable’instructions.50. What is ‘the principle of locality’?Ans: It’s the nature of the processes that they refer only to the small subset of the total dataspace of the process. i.e. the process frequently calls the same subroutines or executes theloop instructions.51. What is the working set of a process?Ans: The set of pages that are referred by the process in the last ‘n’, references, where ‘n’ iscalled the window of the working set of the process.52. What is the window of the working set of a process?Ans: The window of the working set of a process is the total number in which the process hadreferred the set of pages in the working set of the process.53. What is called a page fault?Ans: Page fault is referred to the situation when the process addresses a page in the workingset of the process but the process fails to locate the page in the working set. And on a pagefault the kernel updates the working set by reading the page from the secondary device.
  • 54. What are data structures that are used for Demand Paging?Ans: Kernel contains 4 data structures for Demand paging. They are, Page table entries, Diskblock descriptors, Page frame data table (pfdata), Swap-use table.55. What are the bits that support the demand paging?Ans: Valid, Reference, Modify, Copy on write, Age. These bits are the part of the page tableentry, which includes physical address of the page and protection bits.Page addressAgeCopy on writeModifyReferenceValidProtection56. How the Kernel handles the fork() system call in traditional Unix and in the System VUnix, while swapping?Ans: Kernel in traditional Unix, makes the duplicate copy of the parent’s address space andattaches it to the child’s process, while swapping. Kernel in System V Unix, manipulates theregion tables, page table, and pfdata table entries, by incrementing the reference count of theregion table of shared regions.57. Difference between the fork() and vfork() system call?Ans: During the fork() system call the Kernel makes a copy of the parent process’s addressspace and attaches it to the child process. But the vfork() system call do not makes any copy ofthe parent’s address space, so it is faster than the fork() system call. The child process as aresult of the vfork() system call executes exec() system call. The child process from vfork()system call executes in the parent’s address space (this can overwrite the parent’s data andstack ) which suspends the parent process until the child process exits.58. What is BSS(Block Started by Symbol)?Ans: A data representation at the machine level, that has initial values when a program startsand tells about how much space the kernel allocates for the un-initialized data. Kernel initializesit to zero at run-time.59. What is Page-Stealer process?Ans: This is the Kernel process that makes rooms for the incoming pages, by swapping thememory pages that are not the part of the working set of a process. Page-Stealer is created bythe Kernel at the system initialization and invokes it throughout the lifetime of the system. Kernellocks a region when a process faults on a page in the region, so that page stealer cannot stealthe page, which is being faulted in.60. Name two paging states for a page in memory?Ans: The two paging states are:The page is aging and is not yet eligible for swapping,The page is eligible for swapping but not yet eligible for reassignment to other virtual addressspace.61. What are the phases of swapping a page from the memory?Ans: Page stealer finds the page eligible for swapping and places the page number in the list of
  • pages to be swapped. Kernel copies the page to a swap device when necessary and clears thevalid bit in the page table entry, decrements the pfdata reference count, and places the pfdatatable entry at the end of the free list if its reference count is 0.62. What is page fault? Its types?Ans: Page fault refers to the situation of not having a page in the main memory when anyprocess references it. There are two types of page fault :Validity fault,Protection fault.63. In what way the Fault Handlers and the Interrupt handlers are different?Ans: Fault handlers are also an interrupt handler with an exception that the interrupt handlerscannot sleep. Fault handlers sleep in the context of the process that caused the memory fault.The fault refers to the running process and no arbitrary processes are put to sleep.64. What is validity fault?Ans: If a process referring a page in the main memory whose valid bit is not set, it results invalidity fault. The valid bit is not set for those pages:that are outside the virtual address space of a process,that are the part of the virtual address space of the process but no physical address is assignedto it.65. What does the swapping system do if it identifies the illegal page for swapping?Ans: If the disk block descriptor does not contain any record of the faulted page, then thiscauses the attempted memory reference is invalid and the kernel sends a “Segmentationviolation” signal to the offending process. This happens when the swapping system identifiesany invalid memory reference.66. What are states that the page can be in, after causing a page fault?Ans: On a swap device and not in memory, On the free page list in the main memory, In anexecutable file, Marked “demand zero”, Marked “demand fill”.67. In what way the validity fault handler concludes?Ans: It sets the valid bit of the page by clearing the modify bit. It recalculates the processpriority.68. At what mode the fault handler executes?Ans: At the Kernel Mode.69. What do you mean by the protection fault?Ans: Protection fault refers to the process accessing the pages, which do not have the accesspermission. A process also incur the protection fault when it attempts to write a page whosecopy on write bit was set during the fork() system call.70. How the Kernel handles the copy on write bit of a page, when the bit is set?Ans: In situations like, where the copy on write bit of a page is set and that page is shared bymore than one process, the Kernel allocates new page and copies the content to the new pageand the other processes retain their references to the old page. After copying the Kernelupdates the page table entry with the new page number. Then Kernel decrements the reference
  • count of the old pfdata table entry. In cases like, where the copy on write bit is set and noprocesses are sharing the page, the Kernel allows the physical page to be reused by theprocesses. By doing so, it clears the copy on write bit and disassociates the page from its diskcopy (if one exists), because other process may share the disk copy. Then it removes the pfdatatable entry from the page-queue as the new copy of the virtual page is not on the swap device.It decrements the swap-use count for the page and if count drops to 0, frees the swap space.71. For which kind of fault the page is checked first?Ans: The page is first checked for the validity fault, as soon as it is found that the page is invalid(valid bit is clear), the validity fault handler returns immediately, and the process incur thevalidity page fault. Kernel handles the validity fault and the process will incur the protection faultif any one is present.72. In what way the protection fault handler concludes?Ans: After finishing the execution of the fault handler, it sets the modify and protection bits andclears the copy on write bit. It recalculates the process-priority and checks for signals.73. How the Kernel handles both the page stealer and the fault handler?Ans: The page stealer and the fault handler thrash because of the shortage of the memory. Ifthe sum of the working sets of all processes is greater that the physical memory then the faulthandler will usually sleep because it cannot allocate pages for a process. This results in thereduction of the system throughput because Kernel spends too much time in overhead,rearranging the memory in the frantic pace.74. Explain different types of Unix systems.Ans: The most widely used are: 1. System V (AT&T) 2. AIX (IBM) 3. BSD (Berkeley) 4. Solaris(Sun) 5. Xenix ( A PC version of Unix)75. Explain kernal and shell.Ans: Kernal: It carries out basic operating system functions such as allocating memory,accessing files and handling communications. Shell:A shell provides the user interface to thekernal.There are 3 major shells : C-shell, Bourne shell , Korn shell76. What is ex and vi ?Ans: ex is Unix line editor and vi is the standard Unix screen editor.77. Which are typical system directories below the root directory?Ans: (1)/bin: contains many programs which will be executed by users (2)/etc : files used byadministrator (3)/dev: hardware devices (4)/lib: system libraries (5)/usr: application software(6)/home: home directories for different systems.78. Construct pipes to execute the following jobs?Ans:1. Output of who should be displayed on the screen with value of total number of users whohave logged in displayed at the bottom of the list.2. Output of ls should be displayed on the screen and from this output the lines containing theword ‘poem’ should be counted and the count should be stored in a file.3. Contents of file1 and file2 should be displayed on the screen and this output should be
  • appended in a file.From output of ls the lines containing ‘poem’ should be displayed on the screen along with thecount.4. Name of cities should be accepted from the keyboard . This list should be combined with thelist present in a file. This combined list should be sorted and the sorted list should be stored in afile ‘newcity’.5. All files present in a directory dir1 should be deleted any error while deleting should be storedin a file ‘errorlog’.79.Explain the following commands?$ ls > file1$ banner hi-fi > message$ cat par.3 par.4 par.5 >> report$ cat file1>file1$ date ; who$ date ; who > logfile$ (date ; who) > logfile80. What is the significance of the “tee” command?Ans: It reads the standard input and sends it to the standard output while redirecting a copy ofwhat it has read to the file specified by the user.81. What does the command “ $who | sort –logfile > newfile” do?Ans: The input from a pipe can be combined with the input from a file . The trick is to use thespecial symbol “-“ (a hyphen) for those commands that recognize the hyphen as std input.In the above command the output from who becomes the std input to sort , meanwhile sortopens the file logfile, the contents of this file is sorted together with the output of who (rep by thehyphen) and the sorted output is redirected to the file newfile.82. What does the command “$ls | wc –l > file1” do?Ans: ls becomes the input to wc which counts the number of lines it receives as input andinstead of displaying this count , the value is stored in file1.83.Which of the following commands is not a filter man , (b) cat , (c) pg , (d) headman A filter is a program which can receive a flow of data from std input, process (or filter) it andsend the result to the std output.84. How is the command “$cat file2 “ different from “$cat >file2 and >> redirectionoperators ?Ans: is the output redirection operator when used it overwrites while >> operator appends intothe file.85. Explain the steps that a shell follows while processing a command.Ans: After the command line is terminated by the key, the shell goes ahead with processing thecommand line in one or more passes. The sequence is well defined and assumes the followingorder.Parsing: The shell first breaks up the command line into words, using spaces and the delimiters,unless quoted. All consecutive occurrences of a space or tab are replaced here with a singlespace.Variable evaluation: All words preceded by a $ are valuated as variables, unless quoted or
  • escaped.Command substitution: Any command surrounded by back quotes is executed by the shellwhich then replaces the standard output of the command into the command line.Wild-card interpretation: The shell finally scans the command line for wild-cards (the characters*, ?, [, ]).Any word containing a wild-card is replaced by a sorted list offilenames that match the pattern. The list of these filenames then forms the arguments to thecommand.PATH evaluation: It finally looks for the PATH variable to determine the sequence of directoriesit has to search in order to hunt for the command.86. What difference between cmp and diff commands?Ans: cmp – Compares two files byte by byte and displays the first mismatch diff – tells thechanges to be made to make the files identical87. What is the use of ‘grep’ command?Ans: ‘grep’ is a pattern search command. It searches for the pattern, specified in the commandline with appropriate option, in a file(s).Syntax : grepExample : grep 99mx mcafile88. What is the difference between cat and more command?Ans: Cat displays file contents. If the file is large the contents scroll off the screen before weview it. So command ‘more’ is like a pager which displays the contents page by page.89. Write a command to kill the last background job?Ans: Kill $!90. Which command is used to delete all files in the current directory and all its sub-directories?Ans: rm -r *91. Write a command to display a file’s contents in various formats?Ans: $od -cbd file_name c – character, b – binary (octal), d-decimal, od=Octal Dump.92. What will the following command do?Ans: $ echo *It is similar to ‘ls’ command and displays all the files in the current directory.93. Is it possible to create new a file system in UNIX?Ans: Yes, ‘mkfs’ is used to create a new file system.94. Is it possible to restrict incoming message?Ans: Yes, using the ‘mesg’ command.95. What is the use of the command “ls -x chapter[1-5]”Ans: ls stands for list; so it displays the list of the files that starts with ‘chapter’ with suffix ’1′ to’5′, chapter1, chapter2, and so on.
  • 96. Is ‘du’ a command? If so, what is its use?Ans: Yes, it stands for ‘disk usage’. With the help of this command you can find the diskcapacity and free space of the disk.97. Is it possible to count number char, line in a file; if so, How?Ans: Yes, wc-stands for word count.wc -c for counting number of characters in a file.wc -l for counting lines in a file.98. Name the data structure used to maintain file identification?Ans: ‘inode’, each file has a separate inode and a unique inode number.99. How many prompts are available in a UNIX system?Ans: Two prompts, PS1 (Primary Prompt), PS2 (Secondary Prompt).100. How does the kernel differentiate device files and ordinary files?Ans: Kernel checks ‘type’ field in the file’s inode structure.101. How to switch to a super user status to gain privileges?Ans: Use ‘su’ command. The system asks for password and when valid entry is made the usergains super user (admin) privileges.102. What are shell variables?Ans: Shell variables are special variables, a name-value pair created and maintained by theshell.Example: PATH, HOME, MAIL and TERM103. What is redirection?Ans: Directing the flow of data to the file or from the file for input or output.Example : ls > wc104. How to terminate a process which is running and the specialty on command kill 0?Ans: With the help of kill command we can terminate the process.Syntax: kill pidKill 0 – kills all processes in your system except the login shell.105. What is a pipe and give an example?Ans: A pipe is two or more commands separated by pipe char ‘|’. That tells the shell to arrangefor the output of the preceding command to be passed as input to the following command.Example : ls -l | prThe output for a command ls is the standard input of pr.When a sequence of commands are combined using pipe, then it is called pipeline.106. Explain kill() and its possible return values.Ans: There are four possible results from this call:‘kill()’ returns 0. This implies that a process exists with the given PID, and the system wouldallow you to send signals to it. It is system-dependent whether the process could be a zombie.‘kill()’ returns -1, ‘errno == ESRCH’ either no process exists with the given PID, or securityenhancements are causing the system to deny its existence. (On some systems, the processcould be a zombie.)
  • ‘kill()’ returns -1, ‘errno == EPERM’ the system would not allow you to kill the specified process.This means that either the process exists (again, it could be a zombie) or draconian securityenhancements are present (e.g. your process is not allowed to send signals to *anybody*).‘kill()’ returns -1, with some other value of ‘errno’ you are in trouble! The most-used technique isto assume that success or failure with ‘EPERM’ implies that the process exists, and any othererror implies that it doesn’t.An alternative exists, if you are writing specifically for a system (or all those systems) thatprovide a ‘/proc’ filesystem: checking for the existence of ‘/proc/PID’ may work.