Operating System Imp Questions Part 2
Operating System Imp Questions Part 2
1. Define real time operating system. List it’s any four applications of it.
Ans:
A real time system has well defined fixed time constraints. Processing should be
done within the defined constraints -Hard and Soft real time system.
OR
The real-time operating system used for a real-time application means for those
applications where data processing should be done in the fixed and small quantum
of time.
• Hard real-time
• Soft real-time
Applications:
Ans:
1
a) User Interface:
All operating systems have a user interface that allows users to communicate with
the system.
b) Program execution:
The operating system provides an environment where the user can
conveniently run programs. It also performs other important tasks like
allocation and deallocation of memory, CPU scheduling etc. It also provides
service to end process execution either normally or abnormally by indicating
error.
c) I/O operations:
When a program is running, it may require input/output resources such as a
file or devices such as printer. So the operating system provides a service to
do I/O.
Ans:
OR
Virtual memory is the separation of user logical memory from physical memory.
This separation allows an extremely large virtual memory to be provided for
programmers when only a smaller physical memory is available. Virtual memory
makes the task of programming much easier, because the programmer no longer
needs to worry about the amount of physical memory available, or about what code
can be placed in overlays, but can concentrate instead on the problem to be
programmed.
Ans:
a) sleep Syntax:
sleep
NUMBER[SUFFIX]…
sleep OPTION
3
b) kill
Syntax: kill pid
Ans:
• Name: The symbolic file name is the only information kept in human readable
form.
• Identifier: File system gives a unique tag or number that identifies file within
file system and which is used to refer files internally
• Type: This information is needed for those systems that support different
types.
• Time, Date and User Identification: This information may be kept for
creation, Last modification and last use. These data can be useful for
protection, security and usage monitoring.
Ans:
1. Process management
3. File management
4
4. I/O system management
Process Management:
The operating system manages many kinds of activities ranging from user
programs to system programs like printer spooler, name servers, file server etc.
5
• It is processes, rather than applications, that the operating system controls
and schedules for execution by the CPU. In a singletasking system, the
schedule is straight forward.
• The operating system allows the application to begin running,
suspending the execution only long enough to deal with interrupts and
user input.
Ans:
Types of partitioning
Fixed Partitioning:
Main memory is divided into multiple partitions of fixed size at the time of system
generation. A process may be loaded into a partition of equal size or greater size.
Partitions can be of equal size or unequal size.
Main memory is divided into equal size partitions. Any process with less or equal
size can be loaded in any available partition.
OR
6
Unequal size partitioning:
Main memory is divided into multiple partitions of unequal size. Each process can
be loaded into the smallest partition within which the process will fit.
Variable partitioning:
When a process enters in main memory, it is allocated exact size that is required by
that process. So in this method, partitions can vary in size depending on memory
space required by a process entering in main memory. Operating system maintains
a table indicating which parts of memory are available and which are occupied.
When new process arrives and it needs space, system searches for available memory
space in main memory. If it is available, then memory is allocated to the process by
creating a partition in memory. For example: Consider following table with process
and memory space.
Ans:
o Sequential access:
Information from the file is processed in order i.e. one record after another. It
is commonly used access mode. For example, editors and compilers access
7
files in sequence. A read operation read information from the file in a sequence
i.e. read next reads the next portion of the file and automatically advances a
file pointer. A write operation writes information into the file in a sequence
i.e. write next appends to the end of the file and advances to the end of the
newly written material. Such a file can be reset to the beginning. In some
operating systems, a program may be able to skip forward or backward n
records for some integer n.
o Direct access:
8
order. Direct access method is based on disk model of a file which allows
random access to any file block. For direct access a file is viewed as a
numbered sequence of blocks or records. So we can directly read block 14,
then block 53 and so on. This method is used for immediate access to large
amount of information. Database can be accessed with direct access method.
For example, when query concerning a particular subject arrives, we compute
which block contains the answer and then read that block directly to provide
the desired information. Read n operation is used to read the nth block from
the file whereas write n is used to write in that block. The block numbers
provided by the user to the operating system is a relative block number. A
relative block number is an index relative to the beginning of the file. The first
relative block of file is 0; the next is 1 and so on. Actual absolute disk address
of the block is different from the relative address. The use of relative block
numbers allow the operating system to decide where the file should be placed
and helps t prevent the user from accessing portions of the file system that
may not be part of his file.
9. What is purpose of system call? State two system calls with their functions
Ans:
System call provides an interface between a running program and operating system.
It allows user to access services provided by operating system. This system calls are
procedures written using C, C++ and assembly language instructions. Each
operating system has its own name for each system call. Each system call is
associated with a number that identifies itself.
System calls:
o Process Control:
9
Program in execution is a process. A process to be executed must be loaded in
main memory. while executing it may need to wait, terminate or create &
terminate child processes.
• end, abort
• load, execute
• create process, terminate process
• get process attributes, set process attributes
• wait for time
• wait event, signal event
• allocate and free memory
o File Management:
System allows us to create and delete files. For create and delete operation
system call requires the name of the file and other attributes of the file. File
attributes include file type, file size, protection codes, accounting information
and so on. Systems access these attributes for performing operations on file
and directories. Once the file is created, we can open it and use it. System also
allows performing reading, writing or repositioning operations on file.
o Device Management:
10
When a process is in running state, it requires several resources to execute.
These resources include main memory, disk drives, files and so on. If the
resource is available, it is assigned to the process. Once the resource is
allocated to the process, process can read, write and reposition the device.
o Information Maintenance:
Transferring information between the user program and the operating system
requires system call. System information includes displaying current date and
time, the number of current user, the version number of the operating system,
the amount of free memory or disk space and so on. Operating system keeps
information about all its processes that can be accessed with system calls such
as get process attributes and set process attributes.
o Communication:
11
Processes in the system, communicate with each other. Communication is
done by using two models: message passing and shared memory. For
transferring messages, sender process connects itself to receiving process by
specifying receiving processname or identity. Once the communication is over
system close the connection between communicating processes.
• create, delete communication connection
• send, receive messages
• transfer status information
• attach or detach remote devices.
Ans:
It selects programs from job pool and loads them into the main memory. It
controls the degree of multiprogramming. The degree of multiprogramming
is the number of processes loaded (existing) into the main memory. System
contains I/O bound processes and CPU bound processes. An I/O bound
process spends more time for doing I/O operations whereas CPU bound
process spends more time in doing computations with the CPU. So It is the
12
responsibility of long term scheduler to balance the system by loading some
I/O bound and some CPU bound processed into the main memory. Long term
scheduler executes only when a process leaves the system, so it executes less
frequently. When long term scheduler selects a process from job pool, the state
of process changes from new to ready state.
It is also known as CPU scheduler. This scheduler selects processes that are
ready for execution from the ready queue and allocates the CPU to the selected
process. Frequency of execution of short term scheduler is more than other
schedulers. When short term scheduler selects a process, the state of process
changes from ready to running state.
Ans:
13
It is preemptive scheduling algorithm. A small unit of time known as a time quantum
or time slice is used for pre-emption of a currently running process. Ready queue is
implemented as a circular queue. CPU is assigned to the entire processes one by one,
on first come first serve basis, for a specific time period. Every process executes for
specified time period and CPU is given to the next process when time quantum
expires. A new process is added at the tail of the ready queue when it enters the
system. CPU scheduler selects first process from head of the ready queue and
executes it for a specified time quantum. Once the time quantum expires, dispatcher
is invoked to pre-empt current running process and CPU is given to the next process
placed at the head of the ready queue. The running process may have a CPU burst
time less or greater than time quantum. If burst time of running process is less than
the time quantum then, the process itself releases the CPU. The scheduler then
selects next process from ready queue and executes it. If burst time of running
process is longer than time quantum then, context switch occurs and the process is
place at the tail of ready queue for remaining burst time execution.
Example:
P1 24
P2 3
P3 3
Time quantum: 4 ms
14
CPU is allocated to process P1 for 4 ms. Since it requires another 20 milliseconds,
it is preempted after the first time quantum and the CPU is given to the next process
in the queue, process P2. Process P2 does not need 4 milliseconds, so it quits before
its time quantum expires. The CPU is then given to the next process, process P3.
Once each process has received 1 time quantum, the CPU returns to process P1 for
an additional time quantum.
Ans:
Many systems provide support for both user and kernel threads, resulting in different
multithreading models. Following are three multithreading model:
Many-to-One Model:
• The many-to-one model maps many user-level threads to one kernel thread.
• Thread management is done by the thread library in user space, so it is
efficient; but the entire process will block if a thread makes a blocking system
call.
• Also, because only one thread can access the kernel at a time, multiple threads
are unable to nm in parallel on multiprocessors.
• Example: Green threads- a thread library available for Solaris
15
One-to-One Model:
16
Many-to-Many-Model
17
13. Enlist different file allocation methods? Explain contiguous allocation
method in detail.
Ans:
From the user’s point of view, a file is an abstract data type. It can be created,
opened, written, read, closed and deleted without any real concern for its
implementation. The implementation of a file is a problem for the operating system.
The main problem is how to allocate space to these files so that disk space is
effectively utilized and files can be quickly accessed. Three major methods of
allocating disk space are in wide use:
• Contiguous
• Linked
• Indexed
Contiguous Allocation
18
• Contiguous allocation supports both sequential and direct access
• For direct access to block ‘i’ of a file, which starts at block ‘b’, we can
immediately access block b+i. The difficulty with contiguous allocation is
finding space for a new file
• For direct access to block ‘i’ of a file, which starts at block ‘b’, we can
immediately access block b+i.
• The difficulty with contiguous allocation is finding space for a new file
• If file to be created are ‘n’ blocks long, we must search free space list for ‘n’
free contiguous blocks.
19
Advantages of Contiguous File Allocation Method:
20