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

Operating System (3439)

The document provides information about an operating systems course assignment on operating systems. It defines an operating system as a set of programs that acts as an intermediary between applications software and computer hardware. The main purpose of an operating system is to manage computer resources and provide an interface between the user and hardware. It explains key operating system concepts like processes, memory management, loading and execution of programs, and peripheral controlling. Inter-process communication is also discussed as a way for processes to exchange information and cooperate by either sharing memory or passing messages.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Operating System (3439)

The document provides information about an operating systems course assignment on operating systems. It defines an operating system as a set of programs that acts as an intermediary between applications software and computer hardware. The main purpose of an operating system is to manage computer resources and provide an interface between the user and hardware. It explains key operating system concepts like processes, memory management, loading and execution of programs, and peripheral controlling. Inter-process communication is also discussed as a way for processes to exchange information and cooperate by either sharing memory or passing messages.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Course: Operating System (3439) Semester: Spring, 2020

ASSIGNMENT No. 1
Q. 1 What is meant by an Operating System? Also explain the main purpose of an Operating
System with the help of examples.

Operating System
Overview:
When a brand new computer comes off the factory assembly line, it can do nothing. The
hardware needs software to make it work. Are we talking about applications software
such as word processing or spreadsheet software? Partly. 
But an applications software package does not communicate directly with the hardware.
As shown in Figure 1, between the applications software and the hardware is a software
interface - an operating system.

What is Operating System?


An operating system is a set of programs that lies between applications software and the
computer hardware. Conceptually the operating system software is an intermediary
between the hardware and the applications software. Incidentally, the term system
software is sometimes used interchangeably with operating system, but system software
means all programs related to coordinating computer operations. System software does
include the operating system, but it also includes the BIOS software, drivers, and
service programs.

Purpose and Goals of Operating System:


Operating system works like as bridge in between hardware and software, and primary
purpose and goal of an operating system is manage all resources of hardware and
software that are connect with computer. Without operating system all computer system
are helpless, because operating system create the interface between user and hardware.
When user give any instruction to computer then operating system transform these
instructions in to binary form such as 0 and 1, because computer systems are not able to
understand directly our commands. Computer can understand only machine language.
Now, explain purpose and goals of an operating system for boot up entire system
with the help of boot able terminal like example  When power turn on then micro
processor chip start to install the machine code with the help of RAM to Flash ROM
(Read Only Memory). Operating system allow to this code to initialize for all
components that are associative with computer, and this type of code implemented by
BIOS(Basic Input/output System) in the first sector on the starting of Disk.
The operating system must aware about Memory Management Unit, Power
Management Unit, Task State Segment, and other unit also. With using processor, the
operating system handles all these logical parts, and initializes them. 
Now, one question can arise in your mind that what are the three main purpose and
goals of an operating system. Almost many purpose of operating system but there are
some main purpose of an operating system such as:

 Handle Memory Management


 Perform all Loading and Execution task
 Peripheral Controlling

1. Handle Memory Management:


In the computer, many memory and data execute at a one time, so  operating
system provide the flexibility in between the memory and data during execution
time because without operating system, computer can getting  confliction between
the data and all memories. So, memory management executes many activities such
as Upgrading performance, Execution of multiple processes at a one time, and
Utilization of memory space to all devices.

2. Perform all Loading and Execution Task


Operating system has responsible to load important programs and different
libraries with the help of loader that is very necessary part of the O/S. Its primary
task feed the programs in the memory (such as RAM) for execution the all
instruction without more delay. Operating system is supportable to virtual memory,
in  which loader have not actually the master copy of the content, because loader
only allow the virtual memory subsystem that create the interface between that
memory part which having running program’s code and data of
associated executable content.

3. Peripheral Controlling
Every devices of the computer have own device driver that is piece of the
programming code. These types of the drivers create the interface in between
operating system and devices, and operating system having the all control of
drivers  . All drivers execute on the kernel region of the operating system, and
device drivers have many rights such as Open, Close, Read, Write, and more.
Q. 2 (a) Define the term "Process" with the help of suitable examples.

Process (Computing)
In computing, a process is the instance of a computer program that is being executed
by one or many threads. It contains the program code and its activity. Depending on
the operating system (OS), a process may be made up of multiple threads of
execution that execute instructions concurrently.
While a computer program is a passive collection of instructions, a process is the
actual execution of those instructions. Several processes may be associated with the
same program; for example, opening up several instances of the same program often
results in more than one process being executed.
Multitasking is a method to allow multiple processes to share processors (CPUs) and
other system resources. Each CPU (core) executes a single task at a time. However,
multitasking allows each processor to switch between tasks that are being executed
without having to wait for each task to finish (preemption). Depending on the
operating system implementation, switches could be performed when tasks initiate
and wait for completion of input/output operations, when a task voluntarily yields the
CPU, on hardware interrupts, and when the operating system scheduler decides that a
process has expired its fair share of CPU time (e.g, by the Completely Fair
Scheduler of the Linux kernel).
A common form of multitasking is provided by CPU's time-sharing that is a method
for interleaving the execution of users processes and threads, and even of
independent kernel tasks - although the latter feature is feasible only in
preemptive kernels such as Linux. Preemption has an important side effect for
interactive process that are given higher priority with respect to CPU bound
processes, therefore users are immediately assigned computing resources at the
simple pressing of a key or when moving a mouse. Furthermore, applications like
video and music reproduction are given some kind of real-time priority, preempting
any other lower priority process. In time-sharing systems, context switches are
performed rapidly, which makes it seem like multiple processes are being executed
simultaneously on the same processor. This simultaneous execution of multiple
processes is called concurrency.
For security and reliability, most modern operating systems prevent
direct communication between independent processes, providing strictly mediated
and controlled inter-process communication functionality. It's the main chip in a
computer it processes instruction, performs calculations, and manages flow of
information through a computer system it communicates with input, output, and
storage systems to perform task.
Q2 (b) Why Inter Process Communication is needed in an operating system? Explain it in
detail.

Inter Process Communication


There are numerous reasons for providing an environment or situation which allows
process co-operation:

 Information sharing: Since some users may be interested in the same piece of


information (for example, a shared file), you must provide a situation for
allowing concurrent access to that information.
 Computation speedup: If you want a particular work to run fast, you must break
it into sub-tasks where each of them will get executed in parallel with the other
tasks. Note that such a speed-up can be attained only when the computer has
compound or various processing elements like CPUs or I/O channels.
 Modularity: You may want to build the system in a modular way by dividing the
system functions into split processes or threads.
 Convenience: Even a single user may work on many tasks at a time. For
example, a user may be editing, formatting, printing, and compiling in parallel.
Working together with multiple processes, require an interprocess communication
(IPC) method which will allow them to exchange data along with various
information. There are two primary models of interprocess communication:

1. shared memory and


2. message passing.

In the shared-memory model, a region of memory which is shared by cooperating


processes gets established. Processes can be then able to exchange information by
reading and writing all the data to the shared region. In the message-passing form,
communication takes place by way of messages exchanged among the cooperating
processes.

The two communications models are contrasted in the figure below:

Shared Memory Systems:


Interprocess communication (IPC) usually utilizes shared memory that requires
communicating processes for establishing a region of shared memory. Typically, a
shared-memory region resides within the address space of any process creating the
shared memory segment. Other processes that wish for communicating using this
shared-memory segment must connect it to their address space.
Q. 3 Answer the following questions properly:

i. What is Deadlock? How Deadlock is detected?

Deadlock
In concurrent computing, a deadlock is a state in which each member of a group
waiting for another member, including itself, to take action, such as sending a
message or more commonly releasing a lock. Deadlock is a common problem in
multiprocessing systems, parallel computing, and distributed systems, where
software and hardware locks are used to arbitrate shared resources and
implement process synchronization.

In an operating system, a deadlock occurs when a process or thread enters a


waiting state because a requested system resource is held by another waiting process,
which in turn is waiting for another resource held by another waiting process. If a
process is unable to change its state indefinitely because the resources requested by it
are being used by another waiting process, then the system is said to be in a
deadlock.

Detection
Under the deadlock detection, deadlocks are allowed to occur. Then the state of the
system is examined to detect that a deadlock has occurred and subsequently it is
corrected. An algorithm is employed that tracks resource allocation and process
states, it rolls back and restarts one or more of the processes in order to remove the
detected deadlock. Detecting a deadlock that has already occurred is easily possible
since the resources that each process has locked and/or currently requested are
known to the resource scheduler of the operating system.
After a deadlock is detected, it can be corrected by using one of the following
methods:

1. Process termination: one or more processes involved in the deadlock may be


aborted. One could choose to abort all competing processes involved in the
deadlock. This ensures that deadlock is resolved with certainty and speed. But the
expense is high as partial computations will be lost. Or, one could choose to abort
one process at a time until the deadlock is resolved. This approach has high
overhead because after each abort an algorithm must determine whether the
system is still in deadlock. Several factors must be considered while choosing a
candidate for termination, such as priority and age of the process.
2. Resource preemption: resources allocated to various processes may be
successively preempted and allocated to other processes until the deadlock is
broken.
ii. What are the necessary Conditions for Deadlock?

Necessary Conditions
A deadlock situation on a resource can arise if and only if all of the following
conditions hold simultaneously in a system:[5]

1. Mutual exclusion: At least one resource must be held in a non-shareable mode.


Otherwise, the processes would not be prevented from using the resource when
necessary. Only one process can use the resource at any given instant of time.[6]
2. Hold and wait or resource holding: a process is currently holding at least one
resource and requesting additional resources which are being held by other
processes.
3. No  preemption: a resource can be released only voluntarily by the process
holding it.
4. Circular wait: each process must be waiting for a resource which is being held
by another process, which in turn is waiting for the first process to release the
resource. In general, there is a set of waiting processes, P = {P1, P2, …, PN}, such
that P1 is waiting for a resource held by P2, P2 is waiting for a resource held
by P3 and so on until PN is waiting for a resource held by P1.
These four conditions are known as the Coffman conditions from their first
description in a 1971 article by Edward G. Coffman, Jr.
While these conditions are sufficient to produce a deadlock on single-instance
resource systems, they only indicate the possibility of deadlock on systems having
multiple instances of resources.
Q. 4 Explain the major functions of an operating system with the help of proper examples.

Major Functions of an Operating System


1. Security:
The operating system uses password protection to protect user data and similar other
techniques. it also prevents unauthorized access to programs and user data.

2. Control over System Performance:


Monitors overall system health to help improve performance. records the response
time between service requests and system response to have a complete view of the
system health. This can help improve performance by providing important
information needed to troubleshoot problems.

3. Job Accounting:
Operating system Keeps track of time and resources used by various tasks and
users, this information can be used to track resource usage for a particular user or
group of user.

4. Error Detecting Aids:


Operating system constantly monitors the system to detect errors and avoid the
malfunctioning of computer system.

5. Coordination between Other Software and Users:


Operating systems also coordinate and assign interpreters, compilers, assemblers
and other software to the various users of the computer systems.

6. Memory Management:
The operating system manages the Primary Memory or Main Memory. Main
memory is made up of a large array of bytes or words where each byte or word is
assigned a certain address. Main memory is a fast storage and it can be accessed
directly by the CPU. For a program to be executed, it should be first loaded in the
main memory. An Operating System performs the following activities for memory
management.

It keeps tracks of primary memory, i.e., which bytes of memory are used by which
user program. The memory addresses that have already been allocated and the
memory addresses of the memory that has not yet been used. In multi programming,
the OS decides the order in which process are granted access to memory, and for how
long. It Allocates the memory to a process when the process requests it and
deallocates the memory when the process has terminated or is performing an I/O
operation.

7. Processor Management:
In a multi programming environment, the OS decides the order in which processes
have access to the processor, and how much processing time each process has. This
function of OS is called process scheduling. An Operating System performs the
following activities for processor management.

Keep tracks of the status of processes. The program which performs this task is
known as traffic controller. Allocate the CPU that is processor to a process. De-
allocate processor when a process is no more required.

8. Device Management:
An OS manages device communication via their respective drivers. It performs the
following activities for device management. Keeps tracks of all devices connected to
system. Designate a program responsible for every device known as the input/output
controller. Decides which process gets access to a certain device and for how long.
Allocate devices in an effective and efficient way. Deallocate devices when they are
no longer required.

9. File Management:
A file system is organized into directories for efficient or easy navigation and usage.
These directories may contain other directories and other files. An Operating System
carries out the following file management activities. It keeps track of where
information is stored, user access settings and status of every file and more… These
facilities are collectively known as the file system.
Q. 5 Write short notes on the following topics:

 Resources

Resources are the hardware or software required by a program to complete its


execution. Like for example, in order to print a paper i might require printer, so
printer is also a resource.

The main job of an operating system is to allocate and manage the resource. For
example, if there are multiple programs running on my computer, its the job of my
operating system to provide the resources to program. Now this allocation can be of
two types:

1. In case of the resource which is not shareable, OS will allocate it to one


process for a time, take it out and allocate to other. This process will
continue till all the needs of resources are over.
2. In case of Shareable resources, simultaneous usage of resource occurs.

Also examples of hardware resources are: CPU, Memory, I/O devices, Registers,
Cache and examples of Software resources are: Device Drivers, Semaphores,
Monitors(“This is not the display monitor”).

 Page Replacement Algorithms

Page Replacement Algorithms in Operating Systems:


In an operating system that uses paging for memory management, a page replacement
algorithm is needed to decide which page needs to be replaced when new page comes
in.
Page Fault - A page fault happens when a running program accesses a memory page
that is mapped into the virtual address space, but not loaded in physical memory.
Since actual physical memory is much smaller than virtual memory, page faults
happen. In case of page fault, Operating System might have to replace one of the
existing pages with the newly needed page. Different page replacement algorithms
suggest different ways to decide which page to replace. The target for all algorithms is
to reduce the number of page faults.

Page Replacement Algorithms:


First In First Out (FIFO) – This is the simplest page replacement algorithm. In
this algorithm, the operating system keeps track of all pages in the memory in a
queue, the oldest page is in the front of the queue. When a page needs to be replaced
page in the front of the queue is selected for removal.

You might also like