Solved Os Sppu Q - Paper
Solved Os Sppu Q - Paper
Solved Os Sppu Q - Paper
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).
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.
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
Among all the processes, the one with the greatest priority receives the most CPU time.
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
User can view the logical address of a User can never view physical address of
Visibility
program. program.
Parameter LOGICAL ADDRESS PHYSICAL ADDRESS
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.
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.
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
Ans:
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;
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
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.
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.
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.
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.
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.
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.
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.
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
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.
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
Acpi Used to display the battery status and other ACPI information
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
Ans: #!/bin/bash
read number
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
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
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
Ans:
OR
Q18.What is PC 3? [4]
Q19.Explain Critical section concept with producer and consumer problem. [6]
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.
void Producer(){
while(true){
wait(Empty);
wait(mutex);
add();
signal(mutex);
signal(Full);
void Consumer() {
while(true){
// consumer consumes an item
wait(Full);
wait(mutex);
consume();
signal(mutex);
signal(Empty);
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 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
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
result=$((num1 + num2))