0% found this document useful (0 votes)
14 views

Operating System Imp Questions Part 2

The document outlines important concepts related to operating systems, including definitions and applications of real-time operating systems, services provided by OS, virtual memory, file attributes, and process management. It discusses various scheduling algorithms, particularly the Round Robin algorithm, and explains multithreading models. Additionally, it covers system calls, partitioning methods, and access methods for files.

Uploaded by

omkelkar2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Operating System Imp Questions Part 2

The document outlines important concepts related to operating systems, including definitions and applications of real-time operating systems, services provided by OS, virtual memory, file attributes, and process management. It discusses various scheduling algorithms, particularly the Round Robin algorithm, and explains multithreading models. Additionally, it covers system calls, partitioning methods, and access methods for files.

Uploaded by

omkelkar2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

OPERATING SYSTEM IMP QUESTIONS

1. Define real time operating system. List it’s any four applications of it.

Ans:

Real time Operating System:

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.

Types of real time operating system

• Hard real-time
• Soft real-time

Applications:

• Flight Control System


• Simulations
• Industrial control
• Military applications

2. Explain any 4 services provided by OS.

Ans:

1
a) User Interface:

All operating systems have a user interface that allows users to communicate with
the system.

Three types of user interfaces are available:

• Command line interface (CLI)


• Batch interface
• Graphical user interface (GUI)

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.

d) File system manipulation:


Programs may need to read and write data from and to the files and directories.
Operating system manages the secondary storage. Operating system makes it
easier for user programs to accomplish their task such as opening a file, saving
a file and deleting a file from the storage disk.
2
3. Define virtual memory

Ans:

Virtual memory is a memory management capability of an operating system (OS)


that uses hardware and software to allow a computer to compensate for physical
memory shortages by temporarily transferring data from random access memory
(RAM) to disk storage.

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.

4. Write syntax for following commands:


a) Sleep
b) Kill

Ans:

a) sleep Syntax:
sleep
NUMBER[SUFFIX]…
sleep OPTION

3
b) kill
Syntax: kill pid

5. Describe any four file attributes

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.

6. List components of OS. Explain process management in detail.

Ans:

List of System Components:

1. Process management

2. Main memory management

3. File management

4
4. I/O system management

5. Secondary storage 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.

Each of these activities is encapsulated in a process.

• A process includes the complete execution context (code, data, PC,


registers, OS resources in use etc.).
• The basic unit of software that the operating system deals with in
scheduling the work done by the processor is either a process or a thread,
depending on the operating system.
• It’s tempting to think of a process as an application, but that gives an
incomplete picture of how processes relate to the operating system and
hardware.
• The application you see (word processor or spreadsheet or game) is,
indeed, a process, but that application may cause several other processes
to begin, for tasks like communications with other devices or other
computers.
• There are also numerous processes that run without giving you direct
evidence that they ever exist. A process, then, is software that performs
some action and can be controlled by a user, by other applications or by
the operating system.

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.

7. Explain partitioning and its types.

Ans:

An important operation of memory management is to bring programs into main


memory for execution by the processor. Partitioning is a technique that divides a
memory into multiple partitions. These partitions can be of different size or same
size.

Types of partitioning

• Fixed partitioning i.e. static partitioning


• Variable partitioning i.e. dynamic 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.

Equal size partitioning:

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.

Process Memory space


P1 20 M
P2 14 M
P3 18 M

8. Describe sequential and direct access method.

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.

As shown in above diagram, a file can be rewind (moved in backward


direction) from the current position to start with beginning of the file or it can
be read or write in forward direction.

o Direct access:

It is also called as relative access. A file is made up of fixed length logical


records that allow programs to read and write records rapidly in no particular

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.

• create file, delete file


• open, close
• read, write, reposition
• get file attributes, set device attributes
• logically attach or detach devices

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.

• request device, release device


• read, write, reposition
• get device attributes, set device attributes
• logically attach or detach devices

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.

• get time or date, set time or date


• get system data, set system data
• get process, file, or devices attributes
• set process, file, or devices 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.

10. State and describe types of scheduler.

Ans:

There are three types of scheduler:

• Long term scheduler


• Short term scheduler
• Medium term scheduler

o Long term scheduler:

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.

o Medium term scheduler:

When a process is in running state, due to some interrupt it is blocked. System


swaps out blocked process and store it into a blocked and swapped out process
queue. When space is available in the main memory, the operating system
looks at the list of swapped out but ready processes. The medium term
scheduler selects one process from that list and loads it into the ready queue.
The job of medium term scheduler is to select a process from swapped out
process queue and to load it into the main memory. This scheduler works in
close communication with long term scheduler for loading process into the
main memory.

o Short term scheduler:

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.

11. Explain Round Robin algorithm with suitable example.

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:

Process Burst Time

P1 24

P2 3

P3 3

Time quantum: 4 ms

The resulting RR schedule is as follows:

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.

12. Explain multithreading model in detail.

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:

• The one-to-one model maps each user thread to a kernel thread


• It provides more concurrency than the many-to-one model by allowing
another thread to run when a thread makes a blocking system call; it also
allows multiple threads to run in parallel on multiprocessors.
• The only drawback to this model is that creating a user thread requires creating
the corresponding kernel thread.
• Because the overhead of creating kernel threads can burden the performance
of an application, most implementations of this model restrict the number of
threads supported by the system.
• Linux, along with the family of Windows operating systems, implement the
one-to-one model.

16
Many-to-Many-Model

• The many-to-many model multiplexes many user-level threads to a smaller or


equal number of kernel threads.
• The number of kernel threads may be specific to either a particular application
or a particular machine (an application may be allocated more kernel threads
on a multiprocessor than on a uniprocessor).
• The one-to-one model allows for greater concurrency, but the developer has
to be careful not to create too many threads within an application (and in some
instances may be limited in the number of threads she can create).
• The many-to-many model suffers from neither of these shortcomings:
developers can create as many user threads as necessary, and the
corresponding kernel threads can run in parallel on a multiprocessor
• Also, when a thread performs a blocking system call, the kernel can schedule
another thread for execution.

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

• The contiguous allocation method requires each file to occupy a set of


contiguous addresses on the disk. Disk addresses define a linear ordering on
the disk. Contiguous allocation of a file is defined by the disk address of the
first block and its length. If the file is ‘n’ blocks long and starts at location ‘b’,
then it occupies blocks b, b+1, b+2, - - - - - b+n-1. The directory entry for each
file indicates the address of the starting block and the length of the area
allocated for this file.

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:

a) Supports both sequential and direct access methods.


b) Contiguous allocation is the best form of allocation for sequential files.
Multiple blocks can be brought in at a time to improve I/O performance
for sequential processing.
c) It is also easy to retrieve a single block from a file. For example, if a file
starts at block ‘n’ and the ith block of the file is wanted, its location on
secondary storage is simply n + i.
d) Reading all blocks belonging to each file is very fast.
e) Provides good performance.

Disadvantages of Contiguous File Allocation Method:

a) Suffers from external fragmentation.


b) Very difficult to find contiguous blocks of space for new files.
c) Also with pre-allocation, it is necessary to declare the size of the file at the
time of creation which many a times is difficult to estimate.
d) Compaction may be required and it can be very expensive.

20

You might also like