Solved Os Sppu Q - Paper

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Model Question Answer of operAting systeM

Q1.What is operating system? Explain characteristics of OS. [6]

Ans: An operating system (OS) is the program that, after being initially loaded into the computer by a boot program,
manages all of the other application programs in a computer. The application programs make use of the operating
system by making requests for services through a defined application program interface (API).

Characteristics of Operating System


 Memory Management — It keeps tracks of primary memory i.e what part of it are in use by whom, what part are
not in use etc. Allocates the memory when the process or program request it.
 Processor Management — Allocate the processor(CPU) to a process. Deallocate processor when processor is no
longer required.
 Device Management — Keep tracks of all devices. This is also called I/O controller. Decides which process gets
the device when and for how much time.
 File Management — Allocates the resources. De-allocates the resource. Decides who gets the resources.
 Security — By means of passwords & similar other techniques, preventing unauthorized access to programs & data.
 Error-detecting aids — Production of dumps, traces, error messages and other debugging and error-detecting
methods.

Q2.Explain PCB in brief. [4]

Ans: A process control block (PCB) stores data about the process, such as registers, quantum, priority, and so on.
The process table refers to an array of PCBs, which means that it logically contains a PCB for each of the system’s
active processes. A Process Control Block (PCB) refers to a data structure that keeps track of information about a
specific process. The CPU requires this information to complete the job.

A process’s Process Control Block looks like this:


Process Id

The process Id is a one-of-a-kind identifier for each system process. Each process is given a unique identifier when
it is created.

Program Counter

The address of the next instruction to be executed is specified by the program counter. The address of the program’s
first instruction is used to initialize the program counter before it is executed.

The value of the program counter is incremented automatically to refer to the next instruction when each instruction
is executed. This process continues till the program ends.

Process State

Throughout its existence, each process goes through various phases. The present state of the process is defined by
the process state.

Priority

The priority of a process determines how important it is to complete it.

Among all the processes, the one with the greatest priority receives the most CPU time.

General Purpose Registers

General-purpose registers are used to store data created during the execution of a task. Each and every process
consists of its own set of registers, which its PCB keeps track of.

OR

Q3.Explain logical and physical memory conversion. [6]


Ans: Logical Address is generated by CPU while a program is running. The logical address is virtual address as it
does not exist physically, therefore, it is also known as Virtual Address. This address is used as a reference to access
the physical memory location by CPU. The term Logical Address Space is used for the set of all logical addresses
generated by a program’s perspective.
The hardware device called Memory-Management Unit is used for mapping logical address to its corresponding
physical address.
Physical Address identifies a physical location of required data in a memory. The user never directly deals with the
physical address but can access by its corresponding logical address. The user program generates the logical address
and thinks that the program is running in this logical address but the program needs physical memory for its
execution, therefore, the logical address must be mapped to the physical address by MMU before they are used. The
term Physical Address Space is used for all physical addresses corresponding to the logical addresses in a Logical
address space.

Differences Between Logical and Physical Address in Operating System


1. The basic difference between Logical and physical address is that Logical address is generated by CPU in
perspective of a program whereas the physical address is a location that exists in the memory unit.
2. Logical Address Space is the set of all logical addresses generated by CPU for a program whereas the set of all
physical address mapped to corresponding logical addresses is called Physical Address Space.
3. The logical address does not exist physically in the memory whereas physical address is a location in the
memory that can be accessed physically.
4. Identical logical addresses are generated by Compile-time and Load time address binding methods whereas they
differs from each other in run-time address binding method. Please refer this for details.
5. The logical address is generated by the CPU while the program is running whereas the physical address is
computed by the Memory Management Unit (MMU).
Comparison Chart:

Parameter LOGICAL ADDRESS PHYSICAL ADDRESS

Basic generated by CPU location in a memory unit

Logical Address Space is set of all logical


Address Physical Address is set of all physical addresses
addresses generated by CPU in reference to a
Space mapped to the corresponding logical addresses.
program.

User can view the logical address of a User can never view physical address of
Visibility
program. program.
Parameter LOGICAL ADDRESS PHYSICAL ADDRESS

Generation generated by the CPU Computed by MMU

The user can use the logical address to access The user can indirectly access physical address
Access
the physical address. but not directly.

Editable Logical address can be change. Physical address will not change.

Also called virtual address. real address.

Q4.Write a short note of synchronization. [4]

Ans: Processes Synchronization or Synchronization is the way by which processes that share the same memory
space are managed in an operating system. It helps maintain the consistency of data by using variables or hardware
so that only one process can make changes to the shared memory at a time. There are various solutions for the same
such as semaphores, mutex locks, synchronization hardware, etc.

Q.5What is deadlock? Explain how deadlock can be avoided. [6]

Ans: When two or more processes try to access the critical section at the same time and they fail to access
simultaneously or stuck while accessing the critical section then this condition is known as Deadlock.
1. Every process needs a few resources to finish running.
2. The procedure makes a resource request. If the resource is available, the OS will grant it; otherwise, the
process will wait.
3. When the process is finished, it is released.
Deadlock Characteristics
The deadlock has the following characteristics:
1. Mutual Exclusion
2. Hold and Wait
3. No preemption
4. Circular wait
Deadlock Prevention
We can prevent a Deadlock by eliminating any of the above four conditions.
Eliminate Mutual Exclusion: It is not possible to dis-satisfy the mutual exclusion because some resources, such
as the tape drive and printer, are inherently non-shareable.
Eliminate Hold and wait: Allocate all required resources to the process before the start of its execution, this way
hold and wait condition is eliminated but it will lead to low device utilization. for example, if a process requires a
printer at a later time and we have allocated a printer before the start of its execution printer will remain blocked
till it has completed its execution. The process will make a new request for resources after releasing the current
set of resources. This solution may lead to starvation.
Eliminate No Preemption : Preempt resources from the process when resources are required by other high-
priority processes.
Eliminate Circular Wait : Each resource will be assigned a numerical number. A process can request the
resources to increase/decrease. order of numbering. For Example, if the P1 process is allocated R5 resources, now
next time if P1 asks for R4, R3 lesser than R5 such a request will not be granted, only a request for resources
more than R5 will be granted.
Detection and Recovery: Another approach to dealing with deadlocks is to detect and recover from them when
they occur. This can involve killing one or more of the processes involved in the deadlock or releasing some of
the resources they hold.
Deadlock Avoidance
Resource Allocation Graph
The resource allocation graph (RAG) is used to visualize the system’s current state as a graph. The Graph
includes all processes, the resources that are assigned to them, as well as the resources that each Process requests.
Sometimes, if there are fewer processes, we can quickly spot a deadlock in the system by looking at the graph
rather than the tables we use in Banker’s algorithm. Deadlock avoidance can also be done with Banker’s
Algorithm.
Banker’s Algorithm
Bankers’s Algorithm is a resource allocation and deadlock avoidance algorithm which test all the request made
by processes for resources, it checks for the safe state, and after granting a request system remains in the safe
state it allows the request, and if there is no safe state it doesn’t allow the request made by the process.
Inputs to Banker’s Algorithm
1. Max needs of resources by each process.
2. Currently, allocated resources by each process.
3. Max free available resources in the system.
The request will only be granted under the below condition
1. If the request made by the process is less than equal to the max needed for that process.
2. If the request made by the process is less than equal to the freely available resource in the system.
Timeouts: To avoid deadlocks caused by indefinite waiting, a timeout mechanism can be used to limit the
amount of time a process can wait for a resource. If the help is unavailable within the timeout period, the process
can be forced to release its current resources and try again later.
Example:
Total resources in system:
ABCD
6576
The total number of resources are
Available system resources are:
ABCD
3112
Available resources are
Processes (currently allocated resources):
ABCD
P1 1 2 2 1
P2 1 0 3 3
P3 1 2 1 0
Maximum resources we have for a process
Processes (maximum resources):
ABCD
P1 3 3 2 2
P2 1 2 3 4
P3 1 3 5 0

Need = Maximum Resources Requirement – Currently Allocated Resources.


Need = maximum resources - currently allocated resources.
Processes (need resources):
ABCD
P1 2 1 0 1
P2 0 2 0 1
P3 0 1 4 0

Q.6Describe types of multiprocessors. [4]

Ans:

 Multiprocessors consist of two or more processors.


 Multiple applications can be executed simultaneously. There can be two main types of symmetric or asymmetric
multiprocessing which help many processors to perform different tasks.
 Multiprocessor systems expenses are less than equivalent multiple single processor systems as they utilize the
same resources on a sharing basis.
 It is hard to design Multi-Processor Systems.

Working of Multiprocessing Operating System

 Processor support

 False sharing

Careless use of shared memory structures with OpenMP applications can result in poor performance and limited
scalability. Multiple processors updating adjacent shared data in memory can result in excessive traffic on the
multiprocessor interconnect and, in effect, cause serialization of computations.

Below are the three following conditions when occurring false sharing degrades the performance of the system;

1. Multiple processors modify shared data.


2. Multiple processors update data within the same cache line.
3. This updating frequently occurs (for example, in a tight loop).
 Shared data

When multiple processors access the corresponding data concurrently, there may be a possibility of data
inconsistency, so to safeguard this, we have to use some protocols or a locking scheme.

OR

Q.7Explain any two CPU scheduling algorithms


[6]

Ans: On a single-core processor, a CPU can only execute one instruction at a time. But what if multiple processes
(computer programs) all want to run at the same time? This is known as multitasking, and for it to work, the OS
must let each program in turn run a certain number of instructions on the CPU, swapping between them in short
bursts. The OS will have to control how CPU time (and hence number of CPU instructions) is allocated between
different processes - it will have to schedule the different processes.

First Come, First Served (FCFS)


Whichever program is added to the queue first is run until it finishes. Then the next program in the queue is run, and
so on.

Shortest Job Next (SJN)


For this algorithm, the OS needs to know (or guess) the time each program will take to run. It picks the program
which will take the shortest amount of time as the one to run next.

Priority Scheduling
The OS assigns each program a priority. This could be based on how much memory they take, or how important
they are for maintaining a responsive user interface. The program with the highest priority is picked to run next.

Shortest Remaining Time


This is similar to Shortest Job Next, except that if a new program is started, the OS compares the time it needs with
the time the currently running program has left. If the new program would finish sooner, then the currently running
program is switched out and the CPU starts processing the new program.

Round Robin (RR) scheduling


Time on the CPU is divided into equal parts called “time slices”. Time slices are allocated to each program equally
and cyclically. This means that if we had a list of three programs running, the CPU would run:

 Program 1 for one time slice

 Program 2 for one time slice

 Program 3 for one time slice

and would repeat this order until one of the programs finished.
Multilevel Queues
In this algorithm, programs are split into different queues by type — for example, system programs, or interactive
programs. The programs of each type form a “queue”.

 One algorithm will determine how CPU time is split between these queues. For example, one
possibility is that the queues have different priorities, and programs in higher priority queues
always run before those in lower priority queues (similar to priority scheduling).

 For each queue, a different queue scheduling algorithm will decide how the CPU time is split
within that queue. For example, one queue may use Round Robin scheduling, while another uses
priority scheduling.

Analogy: A Real-Life Queue!


Most of these algorithms can be compared to different ways of managing a real-life queue, such as a school dinner
queue. The most common way to serve school dinners is First Come First Served, but other methods are possible.
The queue could prioritise those who want cold food, as they won’t take up much serving time (Shortest Job Next),
or those who need to get to a lunch club (priority scheduling). Alternatively, different classes may be called to queue
up for lunch at different times (multilevel queueing, with priority queueing between classes and FCFS within
classes).

Q.8What is Mobile operating system? Explain types of Mobile OS. [4]

Ans: The software that allows mobile devices such as phones, tablets, and other smart devices such as wearable
technologies to run applications and other programs is known as a mobile operating system (OS). When a mobile
device is turned on, it typically displays a screen with icons or squares that display information and offer access to
the application.

An Operating System is a software that provides a link between the user and the system hardware. Furthermore, it
manages all interactions between software and hardware. Let's look at some of the features of an operating system
before learning about distinct mobile OS.Cellular and wireless network connectivity, as well as phone access, are all
managed by mobile operating systems.

Types of Mobile Operating Systems

There are various mobile device operating systems available today, but the iPhone's OS, Apple iOS, and Google's
open source OS, Google Android, are two of the most frequently used. These two mobile operating systems respond
differently to mobile computing. Some other Operating System(OS) are given below:

1. Android Operating System: The Android operating system is currently the most widely used. It's an open-source
mobile operating system based on the Linux kernel. Google launched the Android operating system. In 2008, the
first Android device was released.

2. iPhone OS / iOS: Apple created the iOS operating system for use on its devices. The iOS operating system is
currently the most widely used. It's an extremely safe operating system. Other mobile devices do not support the iOS
operating system.
3. Bada (Samsung Electronics): Samsung's Bada mobile operating system was released in 2010. The Samsung Wave
was the first smartphone to run on the bada operating system. Many mobile features are available with the Bada
operating system, including application installation, 3-D graphics, and multipoint-touch.

4. BlackBerry OS: BlackBerry mobile operating system was created by Research In Motion (RIM). This operating
system was created with BlackBerry handheld devices in mind. When used with the BlackBerry Enterprise Server,
this operating system benefits corporate users by allowing synchronization with Novell GroupWise email, Microsoft
Exchange, Lotus Domino, and other business software.

5. Symbian OS: The Symbian operating system is a mobile operating system with a high level of network
connectivity. The Java programming language powers the Symbian operating system. It integrates wireless
communications middleware with personal information management (PIM) capabilities. Symbian Ltd created the
Symbian operating system in 1998 for usage on mobile phones. At the time, Nokia was the first business to deliver
Symbian OS on a mobile phone.

6. Windows Mobile OS: Microsoft created the Windows Mobile OS, which is a mobile operating system. It was
created for smartphones and pocket PCs. Rather than normal icons, the Windows smartphone's screen is covered in
various colorful squares. A lot of huge typography and a basic interface are also included in the design.

Q9. Describe components of RTOS. [6]

Ans: A real-time operating system (RTOS) is an operating system that is used in computing systems that needs
strict completion deadlines for all the tasks that need to be performed on it.

Here the system is connected to an external event, whenever that event is completed a signal is sent to the system
with the help of a sensor. Now that signal is communicated to the system as an interrupt. After the operating system
receives an interrupt, it initiates a process that is associated with it. Once the interrupt is completed, the operating
system handles the power back to the CPU. Now since all this is happening in real-time and there's a need for a
quick response from the system speed is very important here.

Components of Real-Time Operating System (RTOS)

An RTOS may have the following components:

Scheduler: Scheduler guarantees the highest priority process that is executing.


Critical Region: Used for context switching using Mutexes, Locks, etc.

Timer: Time of process execution is maintained with the help of Clocks, Timers, etc.

Power Management: The RTOS system has multiple devices of varying power requirements thus their management
is very important.

Communication Process: With the help of Semaphores, Queues, etc. the process order is decided.

Memory Management: Memory management is used by the real-time operating system to use virtual memory.
Using techniques like paging etc., we can save hardware space by keeping the process that is not in use outside the
RAM.

Peripheral Drivers: As we know in real time system, the system is connected to external events, and in order to send
the interrupt from the external system to the operating system we need device drivers.

Device Management: RTOS system contains multiple devices including the internal system as well as many
peripheral devices and they need to be in sync with each other in order to make the system perform its task. Thus
their management is essential.

Q10.Explain any 2 features of windows operating system control panel. [4]

Ans: A Control panel is a feature of the Windows operating system that contains many tools that help in
configuring and managing the computer's resources. For e.g., the control panel provides the settings for audio, video,
mouse, keyboard, network connections, date and time, installed applications, etc. which the user can change as per
his/her need.

1.File Explorer

It is used to display the files and folders which are on the computer. It is also known as Windows Explorer. It gives
users the ability to browse data on the hard drive, SSD, and other inserted removable disks. It allows the user to
manage the content according to their preference such as a user can delete or rename a file, and search and transfer
data.

2.Internet Browser

One of the major use of computers is to access the web/internet. Therefore, an internet browser is very necessary to
search for anything, view pages, do online shopping, play games, etc. There is a pre-installed internet browser
available in the Windows operating system. From Windows 10 onwards, the Edge internet browser is the default
browser, while earlier internet explorer used to be the default browser.

OR

Q11.Explain applications of RTOS in detail. [6]

Ans: Real-time System has applications in various fields of the technology. Here we will discuss the important
applications of real-time system.
1. Industrial application:
Real-time system has a vast and prominent role in modern industries. Systems are made real time based so that
maximum and accurate output can be obtained. In order to such things real -time systems are used in maximum
industrial organizations. These system somehow lead to the better performance and high productivity in less time.
Some of the examples of industrial applications are: Automated Car Assembly Plant, Chemical Plant etc.
2. Medical Science application:
In the field of medical science, real-time system has a huge impact on the human health and treatment. Due to the
introduction of real-time system in medical science, many lives are saved and treatment of complex diseases has
been turned down to easier ways. People specially related to medical, now feel more relaxed due to these
systems. Some of the examples of medical science applications are: Robot, MRI Scan, Radiation therapy etc.
3. Peripheral Equipment applications:
Real-time system has made the printing of large banners and such things very easier. Once these systems came
into use, the technology world became more strong. Peripheral equipment are used for various purposes. These
systems are embedded with micro chips and perform accurately in order to get the desired response. Some of the
examples of peripheral equipment applications are: Laser printer, fax machine, digital camera etc.
4. Telecommunication applications:
Real-time system map the world in such a way that it can be connected within a short time. Real-time systems
have enabled the whole world to connect via a medium across internet. These systems make the people connect
with each other in no time and feel the real environment of togetherness. Some examples of telecommunication
applications of real-time systems are: Video Conferencing, Cellular system etc.
5. Defense applications:
In the new era of atomic world, defense is able to produce the missiles which have the dangerous powers and
have the great destroying ability. All these systems are real-time system and it provides the system to attack and
also a system to defend. Some of the applications of defense using real time systems are: Missile guidance
system, anti-missile system, Satellite missile system etc.
6. Aerospace applications:
The most powerful use of real time system is in aerospace applications. Basically hard real time systems are used
in aerospace applications. here the delay of even some nano second is not allowed and if it happens, system fails.
Some of the applications of real-time systems in aerospace are: Satellite tracking system, Avionics, Flight
simulation etc.

Q12.Describe any 4 commands of Linux. [4]

Ans:

Commands Description

Used to check whether the calling program has access to a specified file. It can be
Access used to check whether a file exists or not

Used to turn on or turn off the process for accounting or change info process
Accton accounting file

Aclocal Used to automatically generate aclocal.m4 files from configure.in file

Acpi Used to display the battery status and other ACPI information

Tests whether ACPI (Advanced Configuration and Power Interface) subsystem is


Acpi_available available or not

It provides intelligent power management on a system and is used to notify the user-
Acpid space programs about the ACPI events

Addr2line Used to convert addresses into file names and line numbers
It is a Linux version of getty, which is a Unix program running on a host computer
Agetty that manages physical or virtual terminals to allow multi-user access

Instructs the shell to replace one string with another string while executing the
Alias commands

Q13. Write a shell script for reverse order number. [6]

Ans: #!/bin/bash

# Prompt the user for input

echo "Enter a number: "

read number

# Use awk to reverse the digits

reversed_number=$(echo "$number" | awk '{ for(i=length($0);i>0;i--) printf("%s",substr($0,i,1)); }')

# Print the reversed number

echo "Reversed number: $reversed_number"

Q14.Write a short note on Kernel. [4]

Ans: Kernel is central component of an operating system that manages operations of computer and hardware. It
basically manages operations of memory and CPU time. It is core component of an operating system. Kernel acts
as a bridge between applications and data processing performed at hardware level using inter-process
communication and system calls.
Kernel loads first into memory when an operating system is loaded and remains into memory until operating
system is shut down again. It is responsible for various tasks such as disk management, task management, and
memory management.

OR

Q14.Explain loops in Linux shell scripting with examples. [6]

Ans: There are total 3 looping statements that can be used in bash programming
1. while statement
2. for statement
3. until statement
To alter the flow of loop statements, two commands are used they are,
1. break
2. continue
Their descriptions and syntax are as follows:
while statement
Here the command is evaluated and based on the resulting loop will execute, if the command is raise to false then
the loop will be terminated that
while <condition>
do

<command 1>
<command 2>
<etc>
done

for statement
The for loop operates on lists of items. It repeats a set of commands for every item in a list.
Here var is the name of a variable and word1 to wordN are sequences of characters separated by spaces (words).
Each time the for loop executes, the value of the variable var is set to the next word in the list of words, word1 to
wordN.
Syntax:
for <var> in <value1 value2 ... valuen>
do
<command 1>
<command 2>
<etc>
done

until statement
The until loop is executed as many times as the condition/command evaluates too false. The loop terminates
when the condition/command becomes true.
Syntax:
until <condition>
do

<command 1>
<command 2>
<etc>
done

Q.15. What is paging? Explain with diagram. [4]

Ans: Paging is a technique that divides memory into fixed-sized blocks. The main memory is divided into blocks
known as Frames and the logical memory is divided into blocks known as Pages. Paging requires extra time for the
address conversion, so we use a special hardware cache memory known as TLB. This concept of Paging in OS
includes dividing each process in the form of pages of equal size and also, the main memory is divided in the form
of frames of fixed size. Now, each page of the process when retrieved into the main memory, is stored in one frame
of the memory, and hence, it is also important to have the pages and frames of equal size for mapping and maximum
utilization of the memory. Its main advantage is that the pages can be stored at different locations of the memory and
not necessarily in a contiguous manner, though priority is always set to firstly find the contiguous frames for
allocating the pages.
Q16.Explain logical to physical memory mapping. [6]

Ans: To store the data and to manage the processes, we need a large-sized memory and, at the same time, we
need to access the data as fast as possible. But if we increase the size of memory, the access time will also
increase and, as we know, the CPU always generates addresses for secondary memory, i.e. logical addresses. But
we want to access the main memory, so we need Address translation of logical address into physical address.
The main memory interacts with both the user processes and the operating system.So we need to efficiently use
the main memory.Main memory is divided into non-overlapping memory regions called partitions.
The main memory can be broadly allocated in two ways –
1. Contiguous memory allocation
2. Non-Contiguous memory allocation
Contiguous memory allocation can be categorized into two ways :
1. Fixed partition scheme
2. Variable partition scheme.
Different Partition Allocation methods are used in Contiguous memory allocations –
1. First Fit
2. Best Fit
3. Worst Fit
4. Next Fit
Non-Contiguous memory allocation can be categorized into many ways :
1. Paging
2. Multilevel paging
3. Inverted paging
4. Segmentation
5. Segmented paging

Q17.Explain the states of process. [4]

Ans:

A process must pass through at least four states.

 A process must go through a minimum of four states to be considered complete.


 The new state, run state, ready state, and terminate state are the four states.
 However, in case a process also requires I/O, the minimum number of states required is 5.

Only one process can run at a time on a single CPU.

 Any processor can only handle one process at a time.


 When there are n processors in a system, only n processes can run at the same time.

Present in Memory State

Secondary Memory New state

Main Memory Ready state

Main Memory Run state

Main Memory Wait state

Secondary Memory Suspend wait state

Secondary Memory Suspend ready state

OR

Q18.What is PC 3? [4]

Q19.Explain Critical section concept with producer and consumer problem. [6]

Ans: In operating System Producer is a process which is able to produce data/item.

Consumer is a Process that is able to consume the data/item produced by the Producer.

Both Producer and Consumer share a common memory buffer. This buffer is a space of a certain size in the memory
of the system which is used for storage. The producer produces the data into the buffer and the consumer consumes
the data from the buffer.
So, what are the Producer-Consumer Problems?

Producer Process should not produce any data when the shared buffer is full.

Consumer Process should not consume any data when the shared buffer is empty.

The access to the shared buffer should be mutually exclusive i.e at a time only one process should be able to access
the shared buffer and make changes to it.

The Code for producer

void Producer(){

while(true){

// producer produces an item/data

wait(Empty);

wait(mutex);

add();

signal(mutex);

signal(Full);

The code for consumer

void Consumer() {

while(true){
// consumer consumes an item

wait(Full);

wait(mutex);

consume();

signal(mutex);

signal(Empty);

Q20.Explain time slicing. [4]

Ans: Time slicing is a scheduling mechanism/way used in time sharing systems. It is also termed as Round Robin
scheduling. The aim of Round Robin scheduling or time slicing scheduling is to give all processes an equal
opportunity to use CPU. In this type of scheduling, CPU time is divided into slices that are to be allocated to ready
processes. Short processes may be executed within a single time quantum. Long processes may require several
quanta.

The Duration of time slice or Quantum

The performance of time slicing policy is heavily dependent on the size/duration of the time quantum. When the
time quantum is very large, the Round Robin policy becomes a FCFS policy. Too short quantum causes too many
process/context switches and reduces CPU efficiency. So the choice of time quanta is a very important design
decision. Switching from one process to another requires a certain amount of time to save and load registers, update
various tables and lists etc.

Consider, as an example, process switch or context switch takes 5 m sec and time slice duration be 20 m sec. Thus
CPU has to spend 5 m sec on process switching again and again wasting 20% of CPU time. Let the time slice size be
set to say 500 m sec and 10 processes are in the ready queue. If P1 starts executing for first time slice then P2 will
have to wait for 1/2 sec; and waiting time for other processes will increase. The unlucky last (P10) will have to wait
for 5 sec, assuming that all others use their full time slices. To conclude setting the time slice.

OR

Q21.Describe the characteristics of Real time operating system. [6]

Ans: Following are the some of the characteristics of Real-time System:


1. Time Constraints: Time constraints related with real-time systems simply means that time interval allotted
for the response of the ongoing program. This deadline means that the task should be completed within this
time interval. Real-time system is responsible for the completion of all tasks within their time intervals.
2. Correctness: Correctness is one of the prominent part of real-time systems. Real-time systems produce
correct result within the given time interval. If the result is not obtained within the given time interval then
also result is not considered correct. In real-time systems, correctness of result is to obtain correct result in
time constraint.
3. Embedded: All the real-time systems are embedded now-a-days. Embedded system means that combination
of hardware and software designed for a specific purpose. Real-time systems collect the data from the
environment and passes to other components of the system for processing.
4. Safety: Safety is necessary for any system but real-time systems provide critical safety. Real-time systems
also can perform for a long time without failures. It also recovers very soon when failure occurs in the system
and it does not cause any harm to the data and information.
5. Concurrency: Real-time systems are concurrent that means it can respond to a several number of processes
at a time. There are several different tasks going on within the system and it responds accordingly to every
task in short intervals. This makes the real-time systems concurrent systems.
6. Distributed: In various real-time systems, all the components of the systems are connected in a distributed
way. The real-time systems are connected in such a way that different components are at different
geographical locations. Thus all the operations of real-time systems are operated in distributed ways.
7. Stability: Even when the load is very heavy, real-time systems respond in the time constraint i.e. real-time
systems does not delay the result of tasks even when there are several task going on a same time. This brings
the stability in real-time systems.

Q22.Explain the file systems used in windows operating system. [4]

Ans: A file system is a method an operating system uses to store, organize, and manage files and directories on a
storage device. Some common types of file systems include:
1. FAT (File Allocation Table): An older file system used by older versions of Windows and other operating
systems.
2. NTFS (New Technology File System): A modern file system used by Windows. It supports features such as
file and folder permissions, compression, and encryption.
3. ext (Extended File System): A file system commonly used on Linux and Unix-based operating systems.
4. HFS (Hierarchical File System): A file system used by macOS.
5. APFS (Apple File System): A new file system introduced by Apple for their Macs and iOS devices.
The advantages of using a file system
1. Organization: A file system allows files to be organized into directories and subdirectories, making it easier
to manage and locate files.
2. Data protection: File systems often include features such as file and folder permissions, backup and restore,
and error detection and correction, to protect data from loss or corruption.
3. Improved performance: A well-designed file system can improve the performance of reading and writing
data by organizing it efficiently on disk.
Disadvantages of using a file system
1. Compatibility issues: Different file systems may not be compatible with each other, making it difficult to
transfer data between different operating systems.
2. Disk space overhead: File systems may use some disk space to store metadata and other overhead
information, reducing the amount of space available for user data.
3. Vulnerability: File systems can be vulnerable to data corruption, malware, and other security threats, which
can compromise the stability and security of the system.
A file is a collection of related information that is recorded on secondary storage. Or file is a collection of
logically related entities. From the user’s perspective, a file is the smallest allotment of logical secondary
storage.

Q23.Write a shell script for adding two numbers and storing the result in a

variable. [6]

Ans: #!/bin/bash
# Prompt the user for input

read -p "Enter the first number: " num1

read -p "Enter the second number: " num2

# Perform the addition

result=$((num1 + num2))

# Display the result

echo "The result of $num1 + $num2 is: $result"

You might also like