One Line Ques Ans
One Line Ques Ans
©net2net 1
One Line Answers
When a user application requests a service from the operating system through system call, it must change
from user to kernel mode. In kernel mode execution is done on behalf of operating system.
16. What is mode bit?
Computer system must ensure that a user could never gain control of the computer system in monitor
mode and privileged instruction can be executed only in system mode or kernel mode. To ensure this, a bit
called mode bit is used. It is added to computer hardware to indicate the current mode.
17. State the usage of the timer
Timer is commonly used to implement time sharing. A counter is set with the amount of time that a
program is allowed to run. As long as counter is positive, control remains with user program. When the
counter becomes zero the operating system terminates the program. Timer is also used to compute the
current time.
18. Operating System is hardware component. Comment and Justify.
Operating system is a program which helps to execute users program effectively on a computer system.
Operating system acts like as intermediate between user of computer and computer hardware.
19. What are Clustered Systems?
Like multiprocessor systems, clustered systems gather together multiple CPUs to accomplish
computational work. Clustered systems are composed of two or more individual systems coupled
together. They share storage and are closely linked via LAN network.
20. Explain the terms Buffer and Cache.
- A buffer is a memory area that stores data while they are transferred between two devices or between
a device and an application.
- A cache is a region of fast memory that holds copies of data.
21. What is single processor system?
Single processor systems have only one main CPU.
22. What is a multiprocessor system? What are the two types of multiprocessor systems?
Multiprocessor system also known as parallel system or tightly coupled system with two or more CPU’s
sharing common RAM. Types of multiprocessor systems: Symmetric Multiprocessor, Asymmetric
Multiprocessor.
23. What are the advantages of multiprocessor systems?
a. Increased throughput
b. Economical
c. Increased reliability
i. Graceful degradation
ii. Fail-soft systems
24. Explain asymmetric multiprocessing.
1. Each processor is assigned a specific task.
2. Master processor schedules and allocates work to slave processors.
3. More common in extremely large systems.
25. Explain the Web Clipping.
It is one approach for displaying the content in web pages, where only a small subset of a web page is
delivered and displayed on the handheld device.
26. What is asymmetric clustering?
Asymmetric clustering: one server runs the application while other servers’ standby.
27. Difference between multiprogramming and multiprocessor system.
In multiprogramming environment user can execute more than one program concurrently. In
multiprocessor system more than one CPU work in communication sharing common RAM.
28. List the advantages of distributed system.
1. Computation speed up
2. Increased data availability
©net2net 2
One Line Answers
3. Enhanced reliability
4. Efficient functionality
29. What is graceful degradation?
This ability to continue providing service proportional to the level of surviving hardware is called
graceful degradation.
30. What is Fault Tolerance?
Systems designed for graceful degradation are also called fault tolerant
31. What are types of clustered system?
1. Asymmetric clustering: one server runs the application while other servers’ standby.
2. Symmetric clustering: all N hosts are running the application.
32. What is Multiprogramming?
Multiprogramming organizes jobs (code and data) so CPU always has one to execute. A subset of total
jobs in system is kept in memory. One job selected and run via job scheduling. When it has to wait (for
I/O for example), OS switches to another job
33. What features are needed in operating system for multiprogramming?
1. I/O routine supplied by the system
2. Memory management
3. CPU scheduling
4. Allocation of devices
34. What is time sharing?
Time sharing (or multitasking) is a logical extension of multiprogramming. The CPU executes multiple
jobs by switching among them, but the switches occur so frequently that the users can interact with each
program while it is running.
35. What features are needed in operating system for time sharing?
1. File system must be available for user to access data and code
2. Memory management
3. CPU scheduling
4. Job synchronization and have communication facilities.
5. Ensure that dead lock in define waiting time doesn’t occur.
6. All sharing of computer resources.
36. Give storage devices hierarchy according to speed and cost.
©net2net 4
One Line Answers
Chapter 2: System Structure
1. Define booting
The procedure of starting a computer by loading the kernel is known as booting the system.
2. What is bootstrap loader
A small program known as the bootstrap program or bootstrap loader locates the kernel, loads it into main
memory and starts its execution.
3. What is shell?
On some operating system, multiple command interpreters are available to choose, these interpreters are
known as shells.
4. What are the two models used in inter-process communication?
1. Shared memory model
2. Message passing model
5. What is system call?
Operating system provides services by means of system calls. System calls provide the interface between
a running program and the operating system.
6. List the different ways to pass parameters to the operating system in a system call.
1. Pass the parameters in registers
2. Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a
register
3. Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating
system
7. Write any four operating system services.
1. Program execution
2. I/O operations
3. File-system manipulation
4. Communications
5. Error detection.
8. How system calls are supported by Microsoft windows?
Microsoft Windows supports systems calls in form of Win32 APIs. The API (application program
interface) specifies a set of functions that are available to an application programmer, including the
parameters that are passed to each function and the return values the programmer can expect.
9. State the purpose of Command Interpreter.
It reads commands from the user or from a file of commands and executes them, usually by turning them
into one or more system calls. It is usually not part of the kernel since the command interpreter is subject
to changes.
10. Why command interpreter is usually separate from Kernel?
It is usually not part of the kernel since the command interpreter is subject to changes.
11. List any two systems calls for information maintenance.
1. get time or date, set time or date.
2. get system data, set system data.
3. get process, file, or device attributes.
4. set process, file, or device attributes.
12. List different types of systems programs.
1. File management
2. Status information
3. File modification
4. Programming language support
5. Program loading and execution
©net2net 5
One Line Answers
6. Communication
13. List any 4 process control system calls.
1. create process, terminate process
2. end, abort
3. load, execute
4. get process attribute, set process attribute
5. wait time, signal event
6. allocate and free memory
14. List any four Device Management System calls.
1. request device, release device
2. read, write, reposition
3. get device attribute, set device attributes
4. logically attach or detach devices
15. List any four file management system calls.
1. create file, delete file
2. open, close
3. read, write, reposition
4. get file attributes, set file attributes
16. List any four communication system calls.
1. create, delete communication connection
2. send, receive messages
3. transfer status information
4. attach or detach remote devices
17. List protection system calls.
1. The set permission and get permission manipulate the permission settings of resources such as files
and disks.
2. The allow user and deny user system calls, specify whether particular users can or cannot be allowed
to access to certain resources.
18. What is Batch Interface?
This is non-interactive user interface, commands and directives to control those commands are stored into
files (batch files) and those files are executed.
19. What is Graphical User interface (GUI)?
Most commonly user interface. It accepts inputs via devices such as computer keyboard and mouse and
provides articulated graphical output on the computer monitor.
20. List the services provided by the OS to help user.
1. User interface
2. Program execution
3. I/O operations
4. File system manipulation
5. Communication
6. Error detection
21. List the services provided by the OS to help the system operation.
1. Resource allocation
2. Accounting
3. Protection and security
22. List two approaches by which the user can interact with the OS
1. Command line interpreter
©net2net 6
One Line Answers
2. Graphics User Interface (GUI)
23. What are the different OS structures?
1. Simple structure
2. Layered structure
3. Micro-kernels
4. Modules
24. What is virtual machine?
A virtual machine (VM) is a software implementation of a machine (i.e. a computer) that executes
programs like a physical machine.
25. What are the benefits of using virtual machine?
1. Each VM is completely isolated from all other VMs, so no protection is needed.
2. Resources are shared indirectly.
3. System programmer can use their own VM to develop system on VM.
©net2net 7
One Line Answers
11. Define PCB
Each process is represented in the operating system by a process control block (PCB)-also called a task
control block. It contains many pieces of information associated with a specific process.
12. Draw a neat, labeled diagram of process Control Block.
©net2net 8
One Line Answers
A process is independent if it cannot affect or can be affected by the other processes executing in the
system i.e. process that does not share any data (temporary or persistent) with any other process is
independent.
24. Define co-operating process
A process is cooperating if it can affect or can be affected by the other processes executing in the system
i.e. process that shares data with other processes is a cooperating process.
25. What does short term scheduler do?
The short-term scheduler, or CPU scheduler, selects from among the processes that are ready to execute,
and allocates the CPU to one of them.
26. execlp( ) system call is used generally after the fork() system call. Comment.
True – The child process by default gets the duplicate address space as that of the parent. So to replace
that address space with the new address space for the child, execlp() system call is used after fork()
system call.
27. What is the purpose of the following system calls?
a. fork( ) – Used to create new process
b. wait ( ) – Waits for specific child process
c. execlp( ) – Replaces the current process image with new process image
28. What actions are taken upon receiving the exit() system call?
1. Output data from child to parent (via wait)
2. Process’ resources are deallocated by operating system
29. What are the different reasons for which a client can terminate any of its children?
1. Child has exceeded allocated resources
2. Task assigned to child is no longer required
3. If parent is exiting: Some operating system do not allow child to continue if its parent terminates
30. What is a need of process co operation?
1. Information sharing
2. Computation speedup
3. Modularity
4. Convenience
31. What are the models for inter-process communication?
1. Shared memory model
2. Message passing model
32. What are the advantages of shared memory systems?
1. It allows maximum speed and convenience of communication as it can be done at memory speeds.
2. Once shared memory is established all accesses to shared memory are treated as routine memory
accesses and no kernel assistance is required.
33. What is a producer consumer problem?
It is used to illustrate the concept of cooperating processes. A producer process produces information that
is consumed by a consumer process.
e.g. A print program produces characters that are consumed by the printer device drivers.
©net2net 9
One Line Answers
Heavy-weight processes have a significant amount of over head when switching. All the tables have to be
flushed from the processor for each task switch. If a HWP spawns a child HWP using fork(), the only part
shared is the text.
3. List the advantages of multithreaded programming.
1. Responsiveness
2. Resource sharing
3. Economy
4. Utilization of multiprocessor architectures
4. What different multithreaded models are there?
1. Many-to-One Model
2. One-to-one Model
3. Many-to-Many Model
5. What are the types of thread?
1. User thread
2. Kernel thread
6. Define user thread
User level thread or user thread avoids the kernel and manages the table itself. These threads are
implemented in user level libraries rather than via system calls.
7. Define kernel thread
Kernel-level threads or kernel threads are supported and managed by the operating system.
8. What is thread libraries?
A thread library provides the programmer an API for creating and managing threads.
9. What are two ways to implement thread libraries:
1. Provide thread library entirely in user space without kernel support.
2. Provide thread library in kernel space supported by the operating system.
©net2net 10
One Line Answers
Round-Robin algorithm is FCFS with preemption. Each process gets a small unit of CPU time (time
quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to
the end of the ready queue.
6. What is “dispatcher”? What are the functions performed by dispatcher?
The dispatcher is the module that gives control of the CPU to the process selected by the short-term
scheduler.
Functions of dispatcher:
• Switching context
• Switching to user mode
• Jumping to the proper location in the user program to restart that program
7. Define the term ‘Processor sharing’.
The performance of the RR algorithm depends heavily on the size of the time quantum. If the time
quantum is very small (say 1 microsecond), the RR approach is called processor sharing, and appears (in
theory) to the users as though each of n processes has its own processor running at l/n the speed of the real
processor.
8. Define dispatch latency time.
The time it takes for the dispatcher to stop one process and start another running is known as the dispatch
latency.
9. What is CPU-Bound process?
A CPU-bound process, generates I/O requests infrequently, using more of its time doing computation
10. “Every process has equal number of CPU-Burst and I/O-Burst” Yes/No. Comment.
No - An I/O-bound program would typically have many very short CPU bursts. An CPU-bound program
might have a few very long CPU bursts.
11. Define the term ‘Response Time’.
Amount of time it takes from when a request was submitted until the first response is produced, not
output (for time-sharing environment)
12. Define CPU burst.
In the process execution the cycle of CPU execution is called as CPU burst.
13. Define I/O burst.
In the process execution the cycle of I/O is called as I/O burst
14. Define CPU scheduler.
There are several processes in ready queue waiting to be scheduled by CPU. Whenever CPU becomes
idle, the operating system selects one of these processes and allocates CPU to that process. The selection
is done by CPU scheduler.
15. Define CPU Utilization
CPU utilization is the range that the CPU is busy. Normally this range is 0 to 100%. But in real systems,
this range varies from 40% for lightly loaded systems and 90% for heavily loaded system.
16. Define Throughput.
Throughput is the number of processes that are completed per time unit.
17. Define Turnaround time.
The interval from the time of submission of a process to the time of completion is the turnaround time.
Turnaround time is the sum of the periods spent waiting to get into memory, waiting in the ready queue,
executing on the CPU, and doing I/O.
18. Define Waiting time.
Waiting time is the sum of the periods spent waiting in the ready queue.
19. Define Arrival time or submission time.
It is the time at which the process is submitted to the system for the first time and is in hold state.
20. Define Start time.
©net2net 11
One Line Answers
It is the time at which the process is selected by short-term scheduler and is allocated to CPU. It is the
time at which the process starts its execution.
21. Define end time or finish time.
It is the time at which the process finishes its execution.
22. What is convoy effect?
When all the other processes wait for the one big process to get off the CPU then this effect is called as
convoy effect. It results in lower CPU and device utilization than might be possible if the shorter
processes were allowed to go first.
23. Define: Process-contention scope (PCS)
Scheduling technique used to schedule user-level threads belonging to the same process
24. Define: System-contention scope (SCS)
Scheduling technique used to schedule kernel-level threads to the CPUs
25. Define Pthreads.
Refers to the POSIX standard defining an API for thread creation and synchronization. This is a
specification for thread behavior, not an implementation. Operating system designers may implement the
specification in any way they wish.
26. POSIX Pthread API.
It allows specifying either PCS or SCS during thread creation.
27. Pre-emptive and non pre-emptive scheduling.
Under nonpreemptive scheduling, once the CPU has been allocated to a process, the process keeps the
CPU until it releases the CPU either by terminating or by switching to the waiting state.
Under preemptive scheduling, the CPU can be taken back from the process forcibly by a new process.
28. State the criteria when the CPU scheduling decisions take place for a process.
1. Switches from running to waiting state.
2. Switches from running to ready state.
3. Switches from waiting to ready.
4. Terminates.
29. State when pre-emptive and non pre emptive scheduling will take place?
When a process switches from the running state to the waiting state or when process terminates then non-
preemptive scheduling takes place and when a process switches from the running state to the ready state
when a process switches from the waiting state to the ready state preemptive scheduling takes place.
30. An algorithm is more efficient if the throughput is more. Comment.
True – Algorithm is said to efficient if it keeps CPU busy as much as possible. If CPU is busy ultimately
throughput of the system also increases (i.e. number of task completed per time unit).
31. Good operating system always produces minimum response time. State true or false and Justify
your answer.
True - Operating-system developers implement scheduling by maintaining a queue of requests for each
device. When an application issues a blocking I/O system call, the request is placed on the queue for that
device. The I/O scheduler rearranges the order of the queue to improve the overall system efficiency and
the average response time experienced by applications.
32. What do you mean by internal priority and external priority?
Internally defined priorities use some measurable quantity or quantities to compute the priority of a
process. For example, time limits, memory requirements, the number of open files, and the ratio of
average I/O burst to average CPU burst have been used in computing priorities.
External priorities are set by criteria that are external to the operating system, such as the importance of
the process, the type and amount of funds being paid for computer use, the department sponsoring the
work, and other, often political, factors.
33. What is infinite blocking or starvation problem?
A process that is ready to run but lacking the CPU can be considered blocked-waiting for the CPU. A
priority-scheduling algorithm can leave some low-priority processes waiting indefinitely for the CPU.
©net2net 12
One Line Answers
34. What is aging? Where it is used?
Aging is a technique of gradually increasing the priority of processes that wait in the system for a long
time. A solution to the problem of indefinite blockage of low-priority processes is aging.
35. What are the parameters used to define the multilevel feedback queue scheduling
1. The number of queues
2. The scheduling algorithm for each queue
3. The method used to determine when to upgrade a process to a higher priority queue
4. The method used to determine when to demote a process to a lower-priority queue
5. The method used to determine which queue a process will enter when that process needs service
36. Which contention scope values are identified by Pthreads?
1. PTHREAD SCOPE PROCESS schedules threads using PCS scheduling
2. PTHREAD SCOPE SYSTEM schedules threads using SCS scheduling.
37. Which functions are provided by the Pthread IPC for getting and setting the contention scope
policy?
pthread_attr_setscope(pthread_attr_t *attr, int scope)
pthread_attr_getscope(pthread_attr_t *attr, int *scope)
©net2net 13
One Line Answers
The code following exit section i.e. remaining code after exit section is called as remainder section.
11. Preemptive kernel.
A preemptive kernel allows a process to be preempted white it is running in kernel mode.
12. Non Preemptive Kernel.
A non preemptive kernel does not allow a process running in kernel mode to be preempted. It is free from
race condition.
13. What is a Semaphore?
A semaphore is a synchronization tool. A semaphore S is an integer variable that can only be accessed via
two indivisible (atomic) operations: wait and signal
wait (S): while S≤0; // no-op
S--;
signal (S): S++;
Only one process may modify S at a time
14. Why process synchronization is needed?
Concurrent access to the shared data may result in inconsistency. In multi-process environment, to ensure
only one process is manipulating shared data we need process synchronization is needed.
15. List different solutions available to solve critical section problem.
1. Software based solution is known as Peterson’s solution
2. Hardware base solution uses a tool – a lock.
3. TestAndSet() instruction and Swap() instructions.
4. Semaphore
16. What is spinlock?
Semaphore requires busy waiting. This busy waiting wastes CPU cycles. This type of semaphore is also
called as spinlock.
17. What is bounded buffer problem?
1. There is a fixed buffer size.
2. The consumer must wait if the buffer is empty and the producer must wait if the buffer is full.
18. What is reader-writers problem?
1. A data object is shared among several processes
2. Readers: processes that want only to read the shared object
3. Writers: processes that want to write the shared object
4. It’s OK for more than one readers to access the shared object simultaneously
5. If a writer accesses the shared object, then it must have exclusive access
19. What is dinning philosopher problem?
1. When a philosopher gets hungry, he tries to pick up the left and right chopsticks
i. Can pick up one chopstick at a time
2. When a philosopher is finished eating, he puts down both chopsticks
20. What are the types of semaphore?
1. Binary semaphore: takes on only the values 0 and 1.
2. Counting semaphore: can rage over an unrestricted domain.
21. List different classic problems of synchronization
1. Bounded-buffer producer consumer problem
2. Reader-writers problem
3. Dinning philosopher problem
22. What are the solutions to Dining Philosophers problem?
1. Allow at most 4 philosophers to be sitting at the table
2. Allow a philosopher to pick up his chopsticks only if both chopsticks are available
©net2net 14
One Line Answers
3. Use an asymmetric solution: an odd philosopher picks up first his left chopstick and then his right
chopstick, an even philosopher picks up first his right chopstick and then his left chopstick
Chapter 7: Deadlocks
1. Define deadlock.
Deadlock is a situation in a set of blocked processes each holding a resource and waiting to acquire a
resource held by another process in the set.
2. In which sequence, a process utilizes resources?
Each process utilizes a resource as follows:
b. request
c. use
d. release
3. What is system table?
A system table records whether each resource is free or allocated, and, if a resource is allocated, to which
process.
4. What is ‘rollback’?
Preempting resources of process bringing it to safe state and restart it from that state is called rollback.
5. What is a Resource Allocation Graph?
The RAG consists of a set of vertices P={P1,P2,…,Pn} of processes and R={R1,R2,…,Rm} of resources. A
directed edge from a process to a resource, PiRj, implies that Pi has requested Rj. A directed edge from a
resource to a process, RjPi, implies that Rj has been allocated by Pi.
6. What is a claim edge in Resource Allocation Graph?
Claim edge Pi → Rj indicated that process Pi may request resource Rj represented by a dashed line. Claim
edge converts to request edge when a process requests a resource.
7. List the issues that must be addressed when resource is preempted to break deadlock.
1. Selecting victim
2. Rollback
3. Starvation
8. Define safe state
A state is safe if the system can allocate maximum resources to each process in some order and still avoid
a deadlock.
9. Define safe sequence
A sequence of processes <P1, P2, ..., Pn> is a safe sequence for the current allocation state if, for each Pi,
the resources that Pi can still request can be satisfied by the currently available resources plus the
resources held by all the Pj, with j < i.
10. Discuss the symbols used for representation of resource allocation graph.
Pictorially, we represent each process Pi as a circle, and each resource type Ri as a square. Since resource
type Ri may have more than one instance, we represent each such instance as a dot within the square. Note
that a request edge points to only the square Ri, whereas an assignment edge must also designate one of
the dots in the square.
11. What are the disadvantages of safe state method of deadlock avoidance?
Resource utilization may be lower than it would be without a deadlock-avoidance algorithm.
12. Give limitation of resource allocation graph method of deadlock avoidance.
Resource allocation graph method of deadlock avoidance can’t be applied to resources with multiple
instances.
13. List the data structures used in Bankers algorithm.
n – number of processes
m – number of resource types
available[m]
©net2net 15
One Line Answers
max[n,m]
allocation[n.m]
need[n,m]
14. List the data structures used in resource request algorithm.
n – number of processes
m – number of resource types
available[m]
max[n,m]
allocation[n.m]
need[n,m]
request[m]
15. What is wait-for graphs?
If all resources have only a single instance, then we can define a deadlock detection algorithm that uses a
variant of the resource-allocation graph, called a wait-for graph. We obtain this graph from the resource-
allocation graph by removing the nodes of type resource and collapsing the appropriate edges.
©net2net 16
One Line Answers
System language libraries are treated like any other object module and are combined by the loader into the
binary program image is called as static linking
12. What is dynamic linking?
System language libraries are not linked at the time of loading but the linking is postponed until execution
time.
13. What is a hole?
A free contiguous block of available memory is called as hole.
14. What is page?
The logical memory is divided into blocks of same size called as pages.
15. What is frame?
The physical memory is divided into fixed size blocks called frames.
16. What is swapping?
Swapping means temporarily moving process out of memory to a backing store and then bring back into
memory for continued execution.
17. What is the use of cache memory?
The CPU uses cache memory to store instructions that are repeatedly required to run programs, improving
overall system speed. The advantage of cache memory is that the CPU does not have to use
the motherboard’s system bus for data transfer.
18. What is ASID?
An ASID uniquely identifies each process and is used to provide address space protection for that process.
When the TLB attempts to resolve virtual page numbers, it ensures the ASID for the currently running
process matches the ASID associated with the virtual page. If the ASIDs do not match, they are treated as
a TLB miss.
19. What is PTBR
If the page table to be very large (for example, 1 million entries), the use of fast registers to implement the
page table is not feasible. Rather, the page table is kept in main memory, and a page-table base register
(PTBR) points to the page table.
20. What is segmentation?
Segmentation is a memory management scheme that supports the user view of memory.
21. What is sparse address space?
Virtual address spaces that include holes are known as sparse address spaces.
22. What is demand paging?
A strategy to initially load only those pages which are needed is known as demand paging and is
commonly used in virtual memory system.
23. What is pure demand paging?
Start executing a process with no pages in memory. When the operating system sets the instruction pointer
to the first instruction of the process, which is on a non-memory-resident page, the process immediately
faults for the page. After this page is brought into memory, the process continues to execute, faulting as
necessary until every page that it needs is in memory. At that point, it can execute with no more faults.
This scheme is pure demand paging: Never bring a page into memory until it is required.
24. What is TLB miss?
If the page number is not in the TLB then it is known as a TLB miss.
25. Explain Best Fit Allocation Algorithm
Allocate the smallest hole that is big enough. We must search the entire list, unless the list is ordered by
size. This strategy produces the smallest leftover hole.
26. Write one major difference between internal and external fragmentation.
1. Internal fragmentation is the area in a region or a page that is not used by the process it is allocated to.
The space is wasted until the process terminates.
2. External fragmentation occurs when there is enough free space to satisfy a request for memory, but
none of the free "holes" between processes in memory is large enough to satisfy the request.
©net2net 17
One Line Answers
27. What do you mean by Page fault?
If the process tries to access a page that was not brought into memory causes a page-fault trap. This trap is
the result of the operating system's failure to bring the desired page into memory.
28. What is thrashing?
When page fault occurs consecutively for more number of times then this hard paging activity is called
thrashing. In this process, system is spending its more time on paging than executing. Thrashing decreases
performance of system.
29. Define hit ratio
The percentage of times that a page number is found in the associative registers is called the hit ratio.
30. What is Belady’s Anomaly?
Belady’s anomaly reflects the fact that, for some page-replacement algorithms, the page-fault rate may
increase as the number of allocated frames increases.
31. What is re-entrant code?
Reentrant code is non-self-modifying code; it never changes during execution. Thus, two or more
processes can execute the same reentrant code at the same time.
32. “Paging suffers from External Fragmentation”. Comment and justify.
When we use a paging scheme, we have no external fragmentation: Any free frame can be allocated to a
process that needs it.
33. What are zero-fill-on-demand pages?
When a page is to be duplicated using copy-on-write, it is important to see that the free page allocated to it
is zeroed out i.e. its contents have been overwritten with zeros. This is called zero-fill-on-demand.
34. Which page replacement algorithm suffers from Belady’s Anomaly?
FIFO page replacement algorithm suffers from Belady’s anomaly.
35. List the different strategies used to select a free hole in dynamics storage allocation.
1. First-fit
2. Best-fit
3. Worst-fit
36. Define the term ‘backing-store’
It is a fast disk large enough to accommodate copies of all memory images for all users, and provides
direct access to these memory images.
37. What is meant by “Transient code’?
The operating system contains code and buffer space for device drivers. If a device driver is not
commonly used, it is not desirable to keep it in memory, as we might be able to use that space for other
purpose. Such code is called as transient operating system code; it comes and goes as needed.
38. What do you mean by swap-out and swap-in process?
A multiprogramming environment with a RR CPU-scheduling algorithm when a quantum expires, the
memory manager will start to swap-out the process that just finished, and swap-in another process to the
memory space has been freed.
39. What is Roll-out-Roll-in swapping?
In a priority-based scheduling algorithm if a higher-priority process arrives and wants service, the
memory manager can swap-out (roll-out) the lower-priority process so that it can load and execute the
higher-priority process. When the higher-priority process finishes, the lower-priority process can be swap-
in (roll-in) and continued.
40. State 50-percent rule.
Depending on the total amount of memory storage and the average process size, external fragmentation
may be a minor or a major problem. Statistical analysis of first fit, for instance, reveals that, even with
some optimization, given N allocated blocks, another 0.5N blocks will be lost due to fragmentation. That
is, one-third of memory may be unusable! This property is known as the 50-percent rule.
41. What is paging?
©net2net 18
One Line Answers
Paging is a memory-management scheme that permits the physical-address space of a process to be
noncontiguous.
42. In paging, how logical address is represented?
©net2net 19
One Line Answers
52. List different page replacement algorithms
1. FIFO
2. Optimal
3. LRU
4. Second Chance
5. Counting algorithms (MFU, LFU)
53. How is performance of demand paging calculated?
Page Fault Rate 0 ≤ p ≤ 1.0
a. if p = 0, no page faults
b. if p = 1, every reference is a fault
Effective Access Time (EAT) = (1 – p) x memory access + p x (page fault overhead +
swap page out +
swap page in +
restart overhead)
54. What is dirty bit or modify bit?
Page replacement requires 2 page transfers (swap in + swap out). To decrease this overhead associate a
‘dirty’ bit with each page in page table. Initially when page is loaded in memory its dirty bit is set to ‘0’
indicating clean page. When page is modified its dirty bit is set to ‘1’. When page is selected as victim for
replacement check its dirty bit:
a. If it is set then only we swap out that page in backing store
b. Otherwise only swap in desired page.
©net2net 20
One Line Answers
6. Protection
7. Time, date, and user identification
5. Write any four operations that can be performed onto the files.
1. Creating a file.
2. Writing a file.
3. Reading a file.
4. Repositioning within a file.
5. Deleting a file.
6. Truncating a file.
6. List different types of directory structure
1. Single-level
2. Two-level
3. Tree
4. Acylic Graph
5. General Graph
7. What is partition?
A disk is used to store file system. A disk can be partitioned into parts. These parts are known as
partitions, slices or minidisks.
8. What is volume?
Volume is a chunk of storage that holds a file system.
9. Explain single level directory.
The simplest way of maintaining directory structure where all the files are contained in the same
directory. Two users cannot give same file name and search time increases when number of files increase.
10. What is link?
Shared files and subdirectories can be implemented in several ways. A common way used by many of the
UNIX systems, is to create a new directory entry called a link. A link is effectively a pointer to another
file or subdirectory.
11. “External fragmentation is present in linked allocation file system”. Comment and justify.
There is no external fragmentation with linked allocation file system, and any free block on the free-space
list can be used to satisfy a request.
12. What are the operations that can be performed on directory?
1. Search for a file
2. Create a file
3. Delete a file
4. List a directory
5. Rename a file
6. Traverse the file system
13. List different disk allocation methods.
1. Contiguous allocation
2. Linked allocation
3. Index allocation
14. What are the advantages of Indexed Allocation?
The advantages of indexed file allocation are:
1. The absence of external fragmentation and
2. The efficiency of random accessing.
15. What are the different file access methods?
1. Sequential access
2. Random access
©net2net 21
One Line Answers
3. Other access method (relative or index sequential access)
16. What are the different free space management methods?
1. Bitmap/bit vector
2. Linked list
3. Counting
4. Grouping
17. Linked allocation method is more reliable than indexed allocation. Justify.
False - Since the files are linked together by pointers scattered all over the disk, consider what would
happen if a pointer were lost or damaged. A bug in the operating-system software or a disk hardware
failure might result in picking up the wrong pointer.
18. What is cluster?
Clusters are collection of blocks i.e. one cluster can be group of four blocks and it is basic disk allocation
unit.
19. What is FAT?
A section of disk at the beginning of each partition is set aside to contain this table. The table has one
entry for each disk block, and is indexed by block number. The directory entry contains the block number
of the first block of the file. The table entry indexed by that block number then contains the block number
of the next block in the file.
20. Give difference between relative path and absolute path
An absolute path name begins at the root and follows a path down to the specified file, giving the
directory names on the path. A relative path name defines a path from the current directory. If the
current directory is root/spell/mail, then the relative path name prtlfirst refers to the same file as does the
absolute path name root/spell/rnail/prtlfivst.
21. What is garbage collector?
Garbage collector traverses entire file system and marks whatever that can be accessed. Whatever is not
marked by garbage collector is then collected onto a list of free space.
22. What is bit vector?
The free-space list is implemented as a bit map or bit vector. Each block is represented by 1 bit. If the
block is free, the bit is 1; if the block is allocated, the bit is 0.
23. How to calculate location of first free block?
To find the first free block, each word in the bit map is checked to see whether that value is not 0. The
first non-0 word is scanned for the first 1 bit, which is the location of the first free block. The calculation
of the block number is
(number of bits per word) x (number of 0-value words) + offset of first 1 bit.
24. What is free space list?
To keep track of free disk space, the system maintains a free-space list. The free-space list records all free
disk blocks-those not allocated to some file or directory. To create a file, we search the free-space list for
the required amount of space, and allocate that space to the new file. This space is then removed from the
free-space list. When a file is deleted, its disk space is added to the free-space list.
25. What is metaslabs?
Sun’s ZFS creates metaslabs to divide the space on the device into some manageable chunks. A volume
may contain hundreds of metaslabs. Each metaslabs has an associated space map.
26. What is a space map?
The space map is a log of all block activity (i.e. allocation and freeing of blocks) in time order, in
counting format.
©net2net 22
One Line Answers
Paper 2: Theoretical Computer Science & Compiler Construction
Chapter 1: Introduction
1. What is translator? Give one example.
It is a system program that takes as input a program written in one programming language (source) and
produces as output a program in another language (target or object). e.g. Compiler
2. Define Complier.
Complier is a program that reads a program written in one language –the source language- and translates
it into an equivalent program in another language- the target language. In this translation process, the
complier reports to its user the presence of the errors in the source program.
3. Define interpreter.
Interpreter is a language processor program that translates and executes source code directly, without
compiling it to machine code.
4. What do you mean by phase of compiler?
A phase is a logically cohesive (inter related) operation that takes as input one representation of the source
program and produces as output another representation.
5. What is front-end and back-end of the compiler?
Front-end consists of those phases that depend primarily on the source program and largely independent
of the target machine.
Back-end consists of those phases that depend on the target machine language and generally those
portions do not depend on the source language, just the intermediate language.
6. List all phases of compiler in sequence.
1. Lexical Analysis 2. Syntax Analysis
3. Semantic Analysis 4. Intermediate Code Generator
5. Code Optimizer 6. Code Generator
7. What is the main difference between phase and pass of a compiler?
A phase is a sub process of the compilation process whereas combination of one or more phases into a
module is called pass.
8. Define pass of a compiler
In an implementation of a compiler, portion of one or more phases are combined into a module called
pass. A pass reads the source program or the output of the previous pass, makes the transformation
specified by its phases and writes output into an intermediate file, which is read by subsequent pass.
9. Define syntax and semantics.
The rules and regulations used to form a language are known as syntax. The meaning given to a
programming construct is known as semantics.
10. What are the classifications of a compiler?
1. Single-pass compiler.
2. Multi-pass compiler.
3. Load and go compiler.
4. Debugging compiler.
5. Optimizing compiler.
11. What is boot strapping?
Suppose we have a new language L, which we want to make available on several machines say ‘A’ & ‘B’.
We might write for machine ‘A’ a small computer CASA that translates a subset S of language L into the
machine or assembly code of A. this compiler is written in a language that is already available on A.
We than write a compiler CSLA in the simple language S. this program when run through CASA, becomes
CALA, the compiler for complete language L, running on machine A and producing object code for A.
CASA
CSLA CALA
This process is called as bootstrapping.
©net2net 23
One Line Answers
12. Define cross-compiler.
When a compiler runs on one machine and produces object code for another machine such a compiler is
called as cross–compiler.
13. What are advantages of bootstrapping?
1. A compiler can be written in the language it compiles.
2. An optimizing compiler can optimize itself.
14. Multipass compilers are preferable over single pass compilers. Comment.
True – A multi-pass compiler can be made to use less space than a single pass compiler, since the space
occupied by the compiler program for one pass can be reused by following pass.
15. What happens during table management of bookkeeping phase of compilation?
The table management, or bookkeeping, portion of the compiler keeps track of the names used by the
program and records essential information about each, such as its type (integer, real, etc.). The data
structures used to record this information is called a symbol table.
16. Good error handling is difficult. Comment.
Good error handling is difficult because certain errors can mask subsequent errors. Other errors, if not
properly handled, can spawn an avalanche of spurious errors.
17. Define: symbol table
Information about source program (identifiers, type, size, etc.) is stored in a data structure called a symbol
table, which is passed to back end.
18. Define: single-pass compiler
In this type of compiler all phases occur during a single pass i.e. a source program is processed only once,
during the translation.
19. Define: multi-pass compiler
While translating source program into target program, we read through a representation of entire source
program multiple times is called as multi-pass compilers.
20. List the functions that compiler.
1. Translate high level language to low level language.
2. Reporting errors and warnings.
21. Which phase of compiler is also known as scanning phase?
Lexical Analyzer
22. Which phase of compiler is also known as parsing phase?
Syntax Analyzer
Letter Letter/Digit
0 1 2
Delimiter
©net2net 25
One Line Answers
declarations
%%
translation rules
%%
auxiliary functions
18. What is manifest constant?
Manifest constants are identifiers declared to stand for a constant, e.g., the name of a token.
19. State the pattern for regular expression ‘signed number’ in lex language notation.
[+-]?[0-9]+
20. Write the purpose of lex library functions-yylex ( )and yyerror( ).
yylex()- The lexical analyzer yylex() produces tokens consisting of a token name and its associated
attribute value.
yyerror() – Called by scanner or parser to display error encountered.
21. What are sentinels?
The sentinel is a special character that cannot be part of the source program, and a natural choice is the
character eof.
22. How conflict can be resolved in Lex
When several prefixes of the input match one or more patterns:
1. Always prefer a longer prefix to a shorter prefix.
2. If the longest possible prefix matches two or more patterns, prefer the pattern listed first in the Lex
program.
23. Explain the advantage of a lexical analyzer generator.
Advantage of lexical analyzer generator is that human efforts are reduced. Otherwise using handcoding
technique we are only suppose to construct NFA for different regular expressions, convert it to DFA,
minimize it and then convert it into code. This is happening within fraction of seconds using scanner
generator.
24. State the pattern for regular expression “set of a’s and b’s of length 2”, in lex language notation .
[ab]{2}
25. State the pattern for regular expression “any character between ‘P’ and ‘S’ irrespective of its case”,
in lex language notation.
[P-Sp-s]
Chapter 3: Parser
1. What is parser?
A parser for grammar G is a program that takes as input a string w and produces as output either a parse
tree for w, if w is a sentence of G, or an error message indicating that w is not a sentence of G.
2. What are the two functions of parser?
1. Checks whether the tokens appearing in its input, which is the output of the lexical analyzer, occurs in
patterns that are permitted by the specification for the source language (grammar).
2. Imposes a tree like structure that is used by the subsequent phases of the compiler.
3. Define handle.
While reduction we find substring in the sentential form which matches RHS of some production. Such
substring is called handle.
4. What is handle pruning?
The process of discovering a handle in the sentential form & reducing it to the appropriate left-hand side
is called handle pruning.
5. What are the demerits of SLR?
1. It will not produce uniquely defined parsing action tables for all grammars.
©net2net 26
One Line Answers
2. Shift-Reduce conflict.
6. Why LR parsing is good and attractive?
1. LR parsers can be constructed for all programming language constructs for which CFG can be
written.
2. LR parser can detect syntactic error as soon as possible, when left-to-right scan of the input.
7. How will you change the given grammar to an augmented grammar?
If ‘G’ is a grammar with start symbol ‘S’ then GWis the augmented grammar for G, such that GWis G
with a new start symbol SWand with production SW→S.
8. Explain the need of augmentation.
To indicate to the parser that, when it should stop parsing and when to announce acceptance of the input.
Acceptance occurs when the parser is about to reduce by SW→S.
9. Let I is a set of LR(O) items, and X is a grammar symbol. Define GOTO(I, X)
GOTO(I,X)={CLOSURE({AαX.β})|Aα.Xβ is in I}
10. Construct LR(O) item for A→ →∈
LR(0) item for A→∈ is A→•
11. What do LL and LR stand for?
LL – First L indicates leftmost derivation and second L indicates input scanned from left to right.
LR – Input scanned from left to right and generates rightmost derivation in reverse.
12. Construct LR(0) items for following production: A XYZ.
AXYZ yields four items
A•XYZ
AX•YZ
AXY•Z
AXYZ•
13. Explain the function CLOSURE(I).
If I is a set of items for a grammar G, then the set of items CLOSURE(I) is constructed from I by the
rules.
1. Every item in I is in CLOSURE (I)
2. If Aα.Bβ is in CLOSURE (I) and Bγ is a production, add the item B.γ to I, if it isn’t already
there.
14. Define CLOSURE(I) operation in LR parsers.
For LR(1) item I, CLOSURE (I) is constructed as follows:
1. Everything in I is in CLOSURE(I)
2. If [Aα.Bβ,a] is in I and Bγ is a production then add β.γ,b] to CLOSURE (I) for every terminal
‘b’ in FIRST(βa)
15. Which type of conflict is not possible in LR parser?
Shift-Shift conflict is not possible in LR parser.
16. Which kind of parser is most common in compilers?
LALR(Look Ahead Left Right) parser is most common in compilers.
17. Recursive decent parser is bottom up type parser. State True or False.
False
18. What is left recursive grammar?
A grammar G is said to be left-recursive if it has a non-terminal A such that there is a derivation A→Aα
for some α
19. What is left factoring?
If A→αβ|αγ are two A-productions, and the input begins with a non-empty string derived from α, we do
not know whether to expand A to αβ or αγ. Left factoring the above grammar we get following
productions:
©net2net 27
One Line Answers
A→αA’
A’→β|γ
20. Left recursive grammars are not suitable for top down parsing. State true or false.
True.
21. List actions taken by shift reduce parser.
1. Shift
2. Reduce
3. Accept
4. Error
22. Define viable prefixes.
The set of prefixes of right sentential forms that can appear on the stack of a shift reduce parser are called
viable prefixes.
23. List down the conflicts during shift-reduce parsing.
1. Shift/reduce conflict: Parser cannot decide whether to shift or reduce.
2. Reduce/reduce conflict: Parser cannot decide which of the several reductions to make.
24. Differentiate Kernel and non-Kernel items.
Kernel items include the initial item, S’.S and all items whose dots are not at the left end. Whereas the
non-kernel items have their dots at the left end.
25. What are the components of LR parser?
1. An input.
2. An output.
3. A stack.
4. A driver program.
5. A parsing table.
26. List the different techniques to construct an LR parsing table?
1. Simple LR(SLR).
2. Canonical LR.
3. Lookahead LR (LALR).
27. YACC is a parser. State true or false.
False
28. What is the syntax for YACC source specification program?
Declarations
%%
Translation rules
%%
Supporting C-routines
29. How YACC resolves parsing action conflicts?
A reduce/reduce conflict is resolved by choosing the conflicting production listed first in the YACC
specification. A shift/reduce conflict is resolved by shifting action or introduce associativity and
precedence.
30. What are the actions performed by a shift reduce parser?
1. Shift
2. Reduce
3. Accept
4. Error
31. What is a recursive descent parser?
©net2net 28
PAPER –II: THEORETICAL COMPUTER SCIENCE AND COMPILER CONSTRUCTION –II
A parser that uses a set of recursive procedures to recognize its input with no backtracking is called a
recursive-descent parser.
32. Why is the precedence and associativity required in the declaration section of a yacc program?
A shift reduce conflicts can be removed by giving precedence and associativity in the declaration section
of a yacc program?
33. What is an operator grammar?
The grammar not having ∈-production and right-side of each production is not having two adjacent non-
terminals.
e.g. SS+S|S*S|id
34. State the relation between number of states in SLR and LALR parser.
Total number of states in SLR are approximately equal to LALR parser.
35. Do left factoring in the following grammar.
AaBcC | aBb | aB | a
BW
CW
After left factoring
AaBA’|a
A’cC|b|W
BW
CW
36. What is conflict? Which type of conflict cannot occur in LR parsers?
If there are multiple entries in LR parsing table then if say conflict has occur. Reduce/reduce can never
occur in LR parsers.
37. State the meaning of ‘UMINUS’ in yacc.
UMINUS represents unary minus. If used as %prec UMINUS then it indicated give precedence of unary
minus.
©net2net 29
PAPER –II: THEORETICAL COMPUTER SCIENCE AND COMPILER CONSTRUCTION –II
It is computed from the value of attributes at the siblings and parent of that node.
6. Define annotated parse tree.
A parse tree showing the values of attributes at each node is called an annotated parse tree.
7. What do you mean by a syntax tree?
Syntax tree is a variant of a parse tree in which each leaf represents an operand and each interior node
represents an operator.
8. When can semantic analysis be done?
Semantic analysis can be done during syntactic analysis or sometimes it is done at the final code
generation phase.
9. Mention the role of semantic analysis?
1. Semantic analysis checks the source program for semantic errors and gathers information for the
subsequent code-generation phase. It uses hierarchical structure to identify the operators and
operands of expressions and statements.
2. An important component of semantic analysis is type checking .In type checking the compiler
checks that each operator has operands that are permitted by the source language specification. In
such cases, certain programming language supports operand coercion or type coercion also.
10. What is dependency graph?
A dependency graph (DG) depicts the flow of information among the attribute instances in a particular
parse tree; an edge from one attribute instance to another means that the value of the first is needed to
compute the second.
11. What are two important classes of SDDs
1. The “S-attributed” and
2. The more general “L-attributed” SDD’s.
12. What is attribute grammar?
An SDD without side effect is sometimes called an attribute grammar. The rules in an attribute grammar
define the value of an attribute purely in terms of the values of other attributes and constants.
13. What is postfix SDT?
SDT’s with all actions at the right ends of the production bodies are called postfix SDT’s.
14. Give applications of SDT?
1. Construction syntax tree
2. Generating type
©net2net 30
PAPER –II: THEORETICAL COMPUTER SCIENCE AND COMPILER CONSTRUCTION –II
3. Memory management
4. Instruction selection
5. Register allocation
6. Evaluation order
5. Define basic block.
A basic block contains sequence of consecutive statements, which may be entered only at the beginning
and when it is entered it is executed in sequence without halt or possibility of branch.
6. Define flow graph.
Relationships between basic blocks are represented by a directed graph called flow graph.
7. What is code optimization? Explain local optimization.
• It is a program transformation technique applied on intermediate code so that made the code
produced runs faster or takes less space.
• Local optimization applied over small segments of a program consisting of a few source statements.
8. What are the rules to find “leader” in basic block?
- The first statement in a basic block is a leader.
- Any statement which is the target of a conditional or unconditional goto is a leader.
- Any statement which immediately follows a conditional goto is a leader.
9. State some application of DAG
1. eliminating local common sub-expressions
2. eliminating dead code
3. reordering statements that do not depend on one another
4. applying algebraic laws to reorder operands of three-address instructions
10. What are dominators?
We say node d of a flow graph dominates node n, written d dom n, if every path from the entry node of
the flow graph to n goes through d. Note that under this definition, every node dominates itself.
11. What is a dominator tree?
A useful way of presenting dominator information is in a tree, called the dominator tree, in which the
entry node is the root, and each node d dominates only its descendants in the tree.
12. What is the use of dominator?
Dominators are used to detect the loops in a program, during data float analysis.
13. What is the need of ‘code optimization’?
1. To eliminate redundancies in program.
2. Computations in a program are rearranged or rewritten so to execution efficiency is improved,
which results in faster running machine code.
14. List different code optimization techniques.
1. Compile time evaluation
2. Common sub-expression elimination
3. Frequency reduction
4. Dead code elimination
5. Strength reduction.
15. What do you mean by ‘loop invariant’ computation?
This transformation takes on expression that yields the same result independent of the number of times a
loop is executed and places the expression before the loop.
16. What is ‘strength reduction’?
The strength reduction optimization replaces the occurrence of a time consuming operation by an
occurrence of a faster operation.
e.g. X = Y*2; can be replace as X = Y + Y;
©net2net 31
PAPER –II: THEORETICAL COMPUTER SCIENCE AND COMPILER CONSTRUCTION –II
©net2net 32
PAPER –II: THEORETICAL COMPUTER SCIENCE AND COMPILER CONSTRUCTION –II
4. Shift-Reduce conflict can occur in Rarely shift-reduce conflict Reduce-reduce conflict can
SLR can occur. occur in LALR
5. Good method Better method Most powerful (best) method.
6. Memory requirement is less. Memory requirement is Memory requirement is less.
large.
©net2net 33