Os concepts, Lecture notes of Operating Systems

Operating systems

Typology: Lecture notes

2015/2016

Uploaded on 05/26/2016

Rajat.Bhai
Rajat.Bhai 🇮🇳

1 document

1 / 82

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
DC14 System Software and Operating System
1
TYPICAL QUESTIONS & ANSWERS
PART - I
OBJECTIVE TYPE QUESTIONS
Each Question carries 2 marks.
Choose correct or the best alternative in the following:
Q.1 Translator for low level programming language were termed as
(A) Assembler (B) Compiler
(C)
Linker (D) Loader
Ans: (A)
Q.2 Analysis which determines the meaning of a statement once its grammatical structure
becomes known is termed as
(A)
Semantic analysis (B) Syntax analysis
(C) Regular analysis (D) General analysis
Ans: (A)
Q.3 Load address for the first word of the program is called
(A)
Linker address origin (B) load address origin
(C) Phase library (D) absolute library
Ans: (B)
Q.4 Symbolic names can be associated with
(A)
Information (B) data or instruction
(C) operand (D) mnemonic operation
Ans: (B)
Q.5 The translator which perform macro expansion is called a
(A)
Macro processor (B) Macro pre-processor
(C) Micro pre-processor (D) assembler
Ans: (B)
Q.6 Shell is the exclusive feature of
(A)
UNIX (B) DOS
(C) System software (D) Application software
Ans: (A)
Q.7 A program in execution is called
(A)
Process (B) Instruction
(C) Procedure (D) Function
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52

Partial preview of the text

Download Os concepts and more Lecture notes Operating Systems in PDF only on Docsity!

TYPICAL QUESTIONS & ANSWERS

PART - I

OBJECTIVE TYPE QUESTIONS

Each Question carries 2 marks.

Choose correct or the best alternative in the following:

Q.1 Translator for low level programming language were termed as (A) Assembler (B) Compiler (C) Linker (D) Loader

Ans: (A)

Q.2 Analysis which determines the meaning of a statement once its grammatical structure becomes known is termed as (A) Semantic analysis (B) Syntax analysis (C) Regular analysis (D) General analysis

Ans: (A)

Q.3 Load address for the first word of the program is called (A) Linker address origin (B) load address origin (C) Phase library (D) absolute library

Ans: (B)

Q.4 Symbolic names can be associated with (A) Information (B) data or instruction (C) operand (D) mnemonic operation

Ans: (B)

Q.5 The translator which perform macro expansion is called a (A) Macro processor (B) Macro pre-processor (C) Micro pre-processor (D) assembler

Ans: (B)

Q.6 Shell is the exclusive feature of (A) UNIX (B) DOS (C) System software (D) Application software

Ans: (A)

Q. 7 A program in execution is called (A) Process (B) Instruction (C) Procedure (D) Function

Ans: (A)

Q.8 Interval between the time of submission and completion of the job is called (A) Waiting time (B) Turnaround time (C) Throughput (D) Response time

Ans: (B)

Q.9 A scheduler which selects processes from secondary storage device is called (A) Short term scheduler. (B) Long term scheduler. (C) Medium term scheduler. (D) Process scheduler.

Ans: (C)

Q.10 The scheduling in which CPU is allocated to the process with least CPU-burst time is called (A) Priority Scheduling (B) Shortest job first Scheduling (C) Round Robin Scheduling (D) Multilevel Queue Scheduling

Ans: (B)

Q.11 The term ‘page traffic’ describes (A) number of pages in memory at a given instant. (B) number of papers required to be brought in at a given page request. (C) the movement of pages in and out of memory. (D) number of pages of executing programs loaded in memory.

Ans: (C)

Q.12 The “turn-around” time of a user job is the (A) time since its submission to the time its results become available. (B) time duration for which the CPU is allotted to the job. (C) total time taken to execute the job. (D) time taken for the job to move from assembly phase to completion phase.

Ans: (C)

Q.13 Which of the following can be used as a criterion for classification of data structures used in language processing. (A) nature of a data structure (B) purpose of a data structure (C) lifetime of a data structure (D) all of the above.

Ans: (D)

Q.14 Memory utilization factor shall be computed as follows (A) memory in use/allocated memory. (B) memory in use/total memory connected. (C) memory allocated/free existing memory. (D) memory committed/total memory available.

Ans: (A)

Q.22 Which amongst the following is not an advantage of Distributed systems? (A) Reliability (B) Incremental growth (C) Resource sharing (D) None of the above

Ans: (A)

Q.23 An imperative statement (A) Reserves areas of memory and associates names with them (B) Indicates an action to be performed during execution of assembled program (C) Indicates an action to be performed during optimization (D) None of the above

Ans: (B)

Q.24 Which of the following loader is executed when a system is first turned on or restarted (A) Boot loader (B) Compile and Go loader (C) Bootstrap loader (D) Relating loader

Ans: (C)

Q.25 Poor response time is usually caused by (A) Process busy (B) High I/O rates (C) High paging rates (D) Any of the above

Ans: (D)

Q.26 “Throughput” of a system is (A) Number of programs processed by it per unit time (B) Number of times the program is invoked by the system (C) Number of requests made to a program by the system (D) None of the above

Ans: (A)

Q.27 The “blocking factor” of a file is (A) The number of blocks accessible to a file (B) The number of blocks allocated to a file (C) The number of logical records in one physical record (D) None of the above

Ans: (C)

Q.28 Which of these is a component of a process precedence sequence? (A) Process name (B) Sequence operator ‘;’ (C) Concurrency operator ‘,’ (D) All of the above

Ans: (D)

Q.29 Which amongst the following is valid syntax of the Fork and Join Primitive? (A) Fork

Ans: (A)

Q.30 Nested Macro calls are expanded using the (A) FIFO rule (First in first out) (B) LIFO (Last in First out) (C) FILO rule (First in last out) (D) None of the above

Ans: (B)

Q.31 A parser which is a variant of top-down parsing without backtracking is (A) Recursive Descend. (B) Operator Precedence. (C) LL(1) parser. (D) LALR Parser.

Ans: (A)

Q.32 The expansion of nested macro calls follows (A) FIFO rule. (B) LIFO rule. (C) LILO rule. (D) priority rule.

Ans: (B)

Q.33. In a two-pass assembler, the task of the Pass II is to (A) separate the symbol, mnemonic opcode and operand fields. (B) build the symbol table. (C) construct intermediate code. (D) synthesize the target program.

Ans: (D)

Q.34 A linker program (A) places the program in the memory for the purpose of execution. (B) relocates the program to execute from the specific memory area allocated to it. (C) links the program with other programs needed for its execution. (D) interfaces the program with the entities generating its input data.

Ans: (C)

Q.35 Which scheduling policy is most suitable for a time-shared operating system (A) Shortest-job First. (B) Elevator. (C) Round-Robin. (D) First-Come-First-Serve. Ans: (C)

Ans: (D)

Q.43 The main reason to encrypt a file is to ______________. (A) Reduce its size (B) Secure it for transmission (C) Prepare it for backup (D) Include it in the start-up sequence

Ans: (B)

Q.44 Which of the following is not a key piece of information, stored in single page table entry, assuming pure paging and virtual memory (A) Frame number (B) A bit indicating whether the page is in physical memory or on the disk (C) A reference for the disk block that stores the page (D) None of the above

Ans: (C)

Q.45 A UNIX device driver is (A) Structured into two halves called top half and bottom half (B) Three equal partitions (C) Unstructured (D) None of the above

Ans: (A)

Q.46 The following is not a layer of IO management module (A) PIOCS (Physical Input Output Control System) (B) LIOCS (Logical Input Output Control System) (C) FS (File System) (D) MCS (Management Control System)

Ans: (D)

Q.47 Which amongst the following is not a valid page replacement policy? (A) LRU policy (Least Recently Used) (B) FIFO policy (First in first out) (C) RU policy (Recurrently used) (D) Optimal page replacement policy

Ans: (C)

Q.48 Consider a program with a linked origin of 5000. Let the memory area allocated to it have the start address of 70000. Which amongst the following will be the value to be loaded in relocation register? (A) 20000 (B) 50000 (C) 70000 (D) 90000

Ans: (None of the above choice in correct. )

Q.49 An assembly language is a (A) low level programming language

(B) Middle level programming language (C) High level programming language (D) Internet based programming language

Ans: (A)

Q.50 TII stands for (A) Table of incomplete instructions (B) table of information instructions (C) translation of instructions information (D) translation of information instruction

Ans: (A)

Q.51 An analysis, which determines the syntactic structure of the source statement, is called (A) Sementic analysis (B) process analysis (C) Syntax analysis (D) function analysis

Ans: (C)

Q.52 Action implementing instruction’s meaning are a actually carried out by (A) Instruction fetch (B) Instruction decode (C) instruction execution (D) Instruction program

Ans: (C)

Q.53 The field that contains a segment index or an internal index is called (A) target datum (B) target offset (C) segment field (D) fix dat

Ans: (A)

Q.54 A program in execution is called (A) process (B) function (C) CPU (D) Memory

Ans: (A)

Q.55 Jobs which are admitted to the system for processing is called (A) long-term scheduling (B) short-term scheduling (C) medium-term scheduling (D) queuing

Ans: (A)

Q.56 A set of techniques that allow to execute a program which is not entirely in memory is called (A) demand paging (B) virtual memory (C) auxiliary memory (D) secondary memory

Q.64 The total time to prepare a disk drive mechanism for a block of data to be read from is its (A) latency (B) latency plus transmission time (C) latency plus seek time (D) latency plus seek time plus transmission time

Ans: (C)

Q.65 To avoid race condition, the maximum number of processes that may be simultaneously inside the critical section is (A) zero (B) one (C) two (D) more than two

Ans: (B)

Q.66 The memory allocation scheme subject to “external” fragmentation is (A) segmentation (B) swapping (C) pure demand paging (D) multiple fixed contiguous partitions

Ans: (A)

Q.67 Page fault frequency in an operating system is reduced when the (A) processes tend to the I/O-bound (B) size of pages is reduced (C) processes tend to be CPU-bound (D) locality of reference is applicable to the process

Ans: (D)

Q.68 In which of the following page replacement policies Balady’s anomaly occurs? (A) FIFO (B) LRU (C) LFU (D) NRU

Ans: (A)

Q.69 Which of the following are language processors? (A) Assembler (B) Compiler (C) Interpreter (D) All of the above

Ans: (D)

Q.70 Virtual memory can be implemented with (A) Segmentation (B) Paging (C) None (D) all of the above

Ans: (D)

Q.71 Recognition of basic syntactic constructs through reductions, this task is performed by (A) Lexical analysis (B) Syntax analysis

(C) Semantic analysis (D) Structure analysis Ans: (B)

Q.72 A grammar for a programming language is a formal description of (A) Syntax (B) Semantics (C) Structure (D) Code

Ans: (C)

Q.73 ____________ is a technique of temporarily removing inactive programs from the memory of computer system (A) Swapping (B) Spooling (C) Semaphore (D) Scheduler

Ans: (A)

Q.74 ___________ is a technique of improving the priority of process waiting in Queue for CPU allocation (A) Starvation (B) Ageing (C) Revocation (D) Relocation

Ans: (B)

Q.75 ________ is the time required by a sector to reach below read/write head. (A) Seek Time (B) Latency Time (C) Access time (D) None

Ans: (B)

Q.76 Which of the following is most general phase structured grammar? (A) Context – Sensitive (B) Regular (C) Context – Free (D) None of the above

Ans: (A)

Q.77 File record length (A) Should always be fixed (B) Should always be variable (C) Depends upon the size of file (D) Should be chosen to match the data characteristics.

Ans: (D)

Q.78 A public key encryption system (A) Allows only the correct receiver to decode the data (B) Allows only one to decode the transmission. (C) Allows only the correct sender to decode the data. (D) Does not encode the data before transmitting it.

Ans: (A)

Sometimes space and comma are in an alphabet while other times they are meta symbols used for descriptions. A language is defined over an alphabet. For example binary language is defined over alphabet B. A finite sequence of symbols from an alphabet is called string or word. 01110 and 111 are strings from the alphabet B above. aaabccc and b are strings from the alphabet C above. A null string is a string with no symbols, usually denoted by epsilon has zero length.

Q.3. What is parsing? Write down the drawback of top down parsing of backtracking. (7)

Ans: Parsing is the process of analyzing a text, made of a sequence of tokens, to determine its grammatical structure with respect to a given formal grammar. Parsing is also known as syntactic analysis and parser is used for analyzing a text. The task of the parser is essentially to determine if and how the input can be derived from the start symbol of the grammar. The input is a valid input with respect to a given formal grammar if it can be derived from the start symbol of the grammar. Following are drawbacks of top down parsing of backtracking: (i) Semantic actions cannot be performed while making a prediction. The actions must be delayed until the prediction is known to be a part of a successful parse. (ii) Precise error reporting is not possible. A mismatch merely triggers backtracking. A source string is known to be erroneous only after all predictions have failed.

Q.4. Give the Schematic of Interpretation of HLL program and execution of a machine language program by the CPU. (8)

Ans:

The CPU uses a program counter (PC) to note the address of next instruction to be executed. This instruction is subjected to the instruction execution cycle consisting of the following steps:

  1. Fetch the instruction.
  2. Decode the instruction to determine the operation to be performed, and also its operands. 3.Execute the instruction. At the end of the cycle, the instruction address in PC is updated and the cycle is repeated for the next instruction. Program interpretation can proceed in a similar manner. The PC can indicate which statement of the source program is to be

PC Source Program

Data

Interpreter

Errors

Memory CPU

PC Machine language program

Data

Memory

a b

interpreted next. This statement would be subjected to the interpretation cycle, which consists of the following steps:

  1. Fetch the statement.
  2. Analyse the statement and determine its meaning, viz. the computation to be performed and its operands.
  3. Execute the meaning of the statement.

Q.5. Give the difference between multiprogramming and multiprocessing. (5)

Ans: A multiprocessing system is a computer hardware configuration that includes more than one independent processing unit. The term multiprocessing is generally used to refer to large computer hardware complexes found in major scientific or commercial applications. The multiprocessor system is characterized by-increased system throughput and application speedup-parallel processing. The main feature of this architecture is to provide high speed at low cost in comparison to uni- processor. A multiprogramming operating system is system that allows more than one active user program (or part of user program) to be stored in main memory simultaneously. Multi programmed operating systems are fairly sophisticated. All the jobs that enter the system are kept in the job pool. This pool consists of all processes residing on mass storage awaiting allocation of main memory. If several jobs are ready to be brought into memory, and there is not enough room for all of them, then the system must choose among them. A time-sharing system is a multiprogramming system.

Q.6. Write down different system calls for performing different kinds of tasks. (4)

Ans: A system call is a request made by any program to the operating system for performing tasks -- picked from a predefined set -- which the said program does not have required permissions to execute in its own flow of execution. System calls provide the interface between a process and the operating system. Most operations interacting with the system require permissions not available to a user level process, e.g. I/O performed with a device present on the system or any form of communication with other processes requires the use of system calls. The main types of system calls are as follows:

  • Process Control: These types of system calls are used to control the processes. Some examples are end, abort, load, execute, create process, terminate process etc.
  • File Management: These types of system calls are used to manage files. Some examples are Create file, delete file, open, close, read, write etc.
  • Device Management: These types of system calls are used to manage devices. Some examples are Request device, release device, read, write, get device attributes etc.

Q.7. Differentiate between pre-emptive and non-pre-emptive scheduling. (4)

Ans: In a pre-emptive scheduling approach, CPU can be taken away from a process if there is a need while in a non-pre-emptive approach if once a process has been given the CPU, the CPU cannot be taken away from that process, unless the process completes or leaves the CPU for performing an Input Output.

Weak, Busy-wait Semaphores:

  • The simplest way to implement semaphores.
  • Useful when critical sections last for a short time, or we have lots of CPUs.
  • S initialized to positive value (to allow someone in at the beginning).
  • S is an integer variable that, apart from initialization, can only be accessed through 2 atomic and mutually exclusive operations: wait(s): while (s.value != 0); s.value--; signal(s): s.value++;

All happens atomically i.e. wrap pre and post protocols.

Q.10. What are the four necessary conditions of deadlock prevention? (4)

Ans: Four necessary conditions for deadlock prevention:

  1. Removing the mutual exclusion condition means that no process may have exclusive access to a resource. This proves impossible for resources that cannot be spooled, and even with spooled resources deadlock could still occur. Algorithms that avoid mutual exclusion are called non-blocking synchronization algorithms.
    1. The "hold and wait" conditions may be removed by requiring processes to request all the resources they will need before starting up. Another way is to require processes to release all their resources before requesting all the resources they will need.
    2. A "no preemption" (lockout) condition may also be difficult or impossible to avoid as a process has to be able to have a resource for a certain amount of time, or the processing outcome may be inconsistent or thrashing may occur. However, inability to enforce preemption may interfere with a priority algorithm. Algorithms that allow preemption include lock-free and wait-free algorithms and optimistic concurrency control.
    3. The circular wait condition: Algorithms that avoid circular waits include "disable interrupts during critical sections", and "use a hierarchy to determine a partial ordering of resources" and Dijkstra's solution.

Q.11. Define the following: (i) FIFO Page replacement algorithm. (ii) LRU Page replacement algorithm. (6)

Ans: (i) FIFO policy: This policy simply removes pages in the order they arrived in the main memory. Using this policy we simply remove a page based on the time of its arrival in the memory. For example if we have the reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 and 3 frames (3 pages can be in memory at a time per process) then we have 9 page faults as shown

If frames are increased say to 4, then number of page faults also increases, to 10 in this case.

(ii) LRU policy: LRU expands to least recently used. This policy suggests that we re- move a page whose last usage is farthest from current time. For reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5, we have the following page faults

Q.12. List the properties which a hashing function should possess to ensure a good search performance. What approaches are adopted to handle collision? (8)

Ans: A hashing function h should possess the following properties to ensure good search performance: 1.The hashing function should not be sensitive to the symbols used in some source program. That is it should perform equally well for different source programs. 2.The hashing function h should execute reasonably fast. The following approaches are adopted to handle collision are: Chaining: One simple scheme is to chain all collisions in lists attached to the appropriate slot. This allows an unlimited number of collisions to be handled and doesn't require a priori knowledge of how many elements are contained in the collection. The tradeoff is the same as with linked lists versus array implementations of collections: linked list overhead in space and, to a lesser extent, in time. Rehashing: Re-hashing schemes use a second hashing operation when there is a collision. If there is a further collision, we re-hash until an empty "slot" in the table is found. The re-hashing function can either be a new function or a re-application of the original one. As long as the functions are applied to a key in the same order, then a sought key can always be located.

individual instruction, register etc. Assembly language programming is writing machine instructions in mnemonic form, using an assembler to convert these mnemonics into actual processor instructions and associated data. An assembly program contains following three kinds of statements:

  1. Imperative statements: These indicate an action to be performed during execution of the assembled program. Each imperative statement typically translates into one machine instruction.
  2. Declaration statements: The syntax of declaration statements is as follows: [Label] DS [Label] DC ‘’ The DS statement reserves areas of memory and associates names with them. The DC statement constructs memory words containing constants.
  3. Assembler directives: These instruct the assembler to perform certain actions during the assembly of a program. For example START directive indicates that the first word of the target program generated by the assembler should be placed in the memory word with address . The advantages of assembly language program would be
    • reduced errors
    • faster translation times
    • changes could be made easier and faster

Q.14. What is an expression tree? How an expression is evaluated using an expression tree? Discuss its advantages over the other evaluation techniques. (8)

Ans: Algebraic expressions such as a/b+(c-d)e have an inherent tree-like structure. For example, following figure is a representation of the expression in above equation. This kind of tree is called an expression tree.

The terminal nodes (leaves) of an expression tree are the variables or constants in the expression ( a , b , c , d , and e ). The non-terminal nodes of an expression tree are the operators (+, -, , and ) The expression tree is evaluated using a post-order traversal of the expression tree as follows:

  1. If this node has no children, it should return the value of the node
  2. Evaluate the left hand child
  3. Evaluate the right hand child
  4. Then evaluate the operation indicated by the node and return this value An expression tree is advantageous for:
  • Understanding the order of operation. Operations that must be done sooner are further to the right in the tree.
  • Counting the number of terms or factors in an expression. Each term or factor is a child node. For example the expression (a+b)/c+2*d contains two terms.

Q.15. Draw an expression tree for the string. f + (x+y) *((a+b)/(c-d)) Indicate the register requirement for each node and list out the evaluation order for the expression tree. (8)

Ans: An expression tree for the string “f + (x+y) *((a+b)/(c-d))” is given below: Maximun register requirement is 2.

The expression will be evaluated in the following order: resister R1 first, then register R2, and so on.

f + (x+y) * ( (a+b) / (c-d))

Q.16. Explain the following:- (i) Elimination of common sub expressions during code optimisation. (ii) Pure and impure interpreters. (iii) Lexical substitution during macro expansion. (iv)Overlay structured program. (v) Facilities of a debug monitor. (vi) Actions of an interrupt processing routine. (vii) Real time operating system. (viii) Fork-join. (16)

R1 R

R

R

R

R