You are on page 1of 5

OS Assignment 1 (Theory)

Purva Gautam 20184014 CS-B


Ans:1
An Operating System acts as a communication bridge (interface) between the user
and computer hardware. The purpose of an operating system is to provide a platform
on which a user can execute programs in a convenient and efficient manner.
1. Information protection and 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. It includes-
 Availability
 Confidentiality
 Data Integrity
 Authenticity

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. Scheduling and Resource management- The Operating System ensures the


proper use of all the resources available by deciding which resource to be used by
whom for how much time. All the decisions are taken by the Operating System.
 Fairness
 Differential responsiveness
 Efficiency

4. Error Detection and Handling: The Operating System is responsible for


detection of any types of error or bugs that can occur while any task. The well
secured OS sometimes also acts as countermeasure for preventing any sort of
breach to the Computer System from any external source and probably handling
them.

5. Memory management – It keeps tracks of primary memory, i.e., which bytes of


memory are used by which user program. 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.
 Process Isolation
 Automatic allocation and management
 Support of modular programming
 Protection and access control
 Long term storage
Ans:2
The functional steps that are necessary to run a program on a completely dedicated
machine are -
1. Reserve machine time
2. Manually load program into memory
3. Load starting address and begin execution
4. Monitor and control execution of program from console

Ans:3
Operating Systems are installed in different drives and/or partitions which are also
known as boot disks or system disks. The bootstrap program needs to search the file
system to find the operating system kernel, load it into memory, and start its
execution.

Ans:4
Interrupts are signals sent to the CPU by external devices, normally I/O devices.
They tell the CPU to stop its current activities and execute the appropriate part of the
operating system. Interrupts are important because they give the user better control
over the computer. Without interrupts, a user may have to wait for a given application
to have a higher priority over the CPU to run. This ensures that the CPU will deal
with the process immediately. Interrupt is a signal emitted by hardware or software
when a process or an event needs immediate attention. It alerts the processor to a
high priority process requiring interruption of the current working process.
Interrupt handling is a key function in real-time software, and comprises interrupts
and their handlers. Only those physical interrupts which of high enough priority can
be centered into system interrupt table. The software assigns each interrupt to a
handler in the interrupt table. An interrupt handler is just a routine containing a
sequence of operations. Each of these may request input and output while running.

Ans:5
a)
i) One user can read the private data of another user - privacy.
ii) One user can corrupt the private data of another user - integrity.
b) Yes - if we can ensure that the operating system prevents any sharing of data
between users, either for reading or writing, and fairly shares the computer,
then we can achieve the same level of security.

Ans:6
By a secure operating system, we mean that a user program is not able to corrupt
the kernel, prevent it from running, crash the system, violate memory protection, etc.
There are several possible approaches for implementing a secure operating system.
One is to write a simulator for a dual-mode processor (one with a privileged mode)
and to run the operating system on top of this emulator. A slight variant of this is to
run user code only in an emulator; this is the approach you use in Nachos.

Another is to rely upon safe languages. Only executing user programs written in a
safe language such as Java will work, since the language properties guarantee that
arbitrary writes to memory aren't allowed and the instruction set is limited. Note here
that the user doesn't get to choose arbitrary machine code to run—the code run is
the result of just-in-time compiling the Java code. Similar to this is only running code
which has been produced by a trusted compiler which is known to check memory
addresses and not output privileged instructions.

It is not enough to have the kernel scan the user code for bad instructions before
executing it, if the code may have been produced by an arbitrary compiler. First, bad
instructions may not be easy to identify—for example, they might be a write
instruction which happens to overwrite critical data, but which is not easily identified
as such. Directly executing user code is also dangerous because the user code may
do something indirect such as overwriting its code or writing out new code to a new
page of memory and them jumping to it, and this code would then not be checked for
security.

Similarly, asking the processor to check with the OS before executing each
instruction doesn't quite work. I don't know of a processor which has a mode quite
like this. Even if one did, that would essentially amount to having a mode bit—there
has to be some way for the processor to know to check user code but not the
operating system code itself. To make this work, you can use a full emulator (as
described earlier).

Ans:7
It reads commands from the user or from a file of commands and executes
them, usually by turning them into one or more system calls. It is usually not
part of the kernel since the command interpreter is subject to changes. An
user should be able to develop a new command interpreter using the system‐call
interface provided by the operating system. The command interpreter allows an
user to create and manage processes and also determine ways by which they
communicate (such as through pipes and files). As all of this functionality could be
accessed by an user‐level program using the system valls, it should be possible
for the user to develop a new command‐line interpreter.

Ans:8
1. In response to a clock interrupt, the OS saves the PC and user stack pointer
of the currently executing process, and transfers control to the kernel clock
interrupt handler.
2. The clock interrupt handler saves the rest of the registers, as well as other
machine state, such as the state of the floating point registers, in the process
PCB.
3. The OS invokes the scheduler to determine the next process to execute.
4. The OS then retrieves the state of the next process from its PCB, and
restores the registers. This restore operation takes the processor back to the
state in which this process was previously interrupted, executing in user code
with user mode privileges.

Ans:9

● New (Create) – In this step, the process is about to be created but not yet
created, it is the program which is present in secondary memory that will be
picked up by OS to create the process.
● Ready – New -> Ready to run. After the creation of a process, the process
enters the ready state i.e. the process is loaded into the main memory. The
process here is ready to run and is waiting to get the CPU time for its
execution. Processes that are ready for execution by the CPU are maintained
in a queue for ready processes.
● Run – The process is chosen by CPU for execution and the instructions within
the process are executed by any one of the available CPU cores.
● Blocked or wait – Whenever the process requests access to I/O or needs
input from the user or needs access to a critical region(the lock for which is
already acquired) it enters the blocked or wait state. The process continues to
wait in the main memory and does not require CPU. Once the I/O operation is
completed the process goes to the ready state.
● Terminated or completed – Process is killed as well as PCB is deleted.
● Suspend ready – Process that was initially in the ready state but were
swapped out of main memory(refer Virtual Memory topic) and placed onto
external storage by scheduler are said to be in suspend ready state. The
process will transition back to ready state whenever the process is again
brought onto the main memory.
● Suspend wait or suspend blocked – Similar to suspend ready but uses the
process which was performing I/O operation and lack of main memory caused
them to move to secondary memory.
When work is finished it may go to suspend ready.

Ans:10
a) Batch - Jobs with similar needs are batched together and run through the
computer as a group by an operator or automatic job sequencer. Performance
is increased by attempting to keep CPU and I/O devices busy at all times
through buffering, off-line operation, spooling, and multiprogramming. Batch is
good for executing large jobs that need little interaction; it can be submitted
and picked up later.
b) Interactive - This system is composed of many short transactions where the
results of the next transaction may be unpredictable. Response time needs to
be short (seconds) since the user submits and waits for the result.
c) Time sharing - This systems uses CPU scheduling and multiprogramming to
provide economical interactive use of a system. The CPU switches rapidly
from one user to another. Instead of having a job defined by spooled card
images, each program reads its next control card from the terminal, and
output is normally printed immediately to the screen.
d) Real time - . Often used in a dedicated application, this system reads
information from sensors and must respond within a fixed amount of time to
ensure correct performance.
e) Network - Provides operating system features across a network such as file
sharing.
f) Parallel (SMP) - Used in systems where there are multiple CPU's each
running the same copy of the operating system. Communication takes place
across the system bus.
g) Distributed - This system distributes computation among several physical
processors. The processors do not share memory or a clock. Instead, each
processor has its own local memory. They communicate with each other
through various communication lines, such as a high- speed bus or local area
network.
h) Clustered - . A clustered system combines multiple computers into a single
system to perform computational task distributed across the cluster.
i) Handheld - A small computer system that performs simple tasks such as
calendars, email, and web browsing. Handheld systems differ from traditional
desktop systems with smaller memory and display screens and slower
processors.

You might also like