You are on page 1of 6

Operating System

Assignment 1
Submitted to: Arslan Amjad

RIYAN IRFAN
BSE193032
SECTION S2
Question 1
An operating system (OS) is the program that, after being initially loaded into the computer by a boot program.
What does this program (OS) do? Write at least five functionalities of OS.

Answer
An operating system (OS) is system software that manages computer hardware and software resources and
provides common services for computer programs. The operating system is a component of the system software
in a computer system. Application programs usually require an operating system to function.

Functionalities
1. Process Management
The Operating System also Treats the Process Management means all the Processes those are given by
the user or the Process those are systems own Process are Handled by the Operating System .
2. Device Management or IO Management
 An Operating System manages device communication via their respective drivers. It does the
following activities for device management
 Keeps tracks of all devices. Program responsible for this task is known as the I/O controller.
 Decides which process gets the device when and for how much time.
 Allocates the device in the efficient way.
 De-allocates devices.
3. Security
Security refers to providing a protection system to computer system resources such as CPU, memory,
disk, software programs and most importantly data/information stored in the computer system. If a
computer program is run by an unauthorized user, then he/she may cause severe damage to computer or
data stored in it. So a computer system must be protected against unauthorized access, malicious access
to system memory, viruses, worms etc.
 Authentication
 One Time passwords
 Program Threats
 System Threats
 Computer Security Classifications
4. Job accounting
Operating system performs the function of job accounting by keeping the track of time and resource used
by several jobs and users.
5. Coordination between other software and user
The operating system also performs the task of coordination between other software and users. OS directs
as well as allocates assemblers, interpreters, compilers, and other software to different computer system
users.
Question 2
There is a hierarchy of memories used in a computer system such as registers, cache, main memory and Hard
disk. What is the need of this hierarchy? What is the concept of principle of locality?

Answer
The hierarchical arrangement of storage in current computer architectures is called the memory hierarchy. It is
designed to take advantage of memory locality in computer programs. Each level of the hierarchy is of higher
speed and lower latency, and is of smaller size, than lower levels. Not only that the fast memory has low storage
capacity but it needs power supply till the information needs to be stored and are costly. Memories with less cost
have high access time. Thus, the cost versus access time paves the way for memory hierarchy. It is used to get
high access rate at low cost of memory.

Principle of Locality
In computer science, locality of reference, also known as the principle of locality, is the tendency of a processor
to access the same set of memory locations repetitively over a short period of time. There are two basic types of
reference locality, temporal and spatial locality.

Temporal Locality
Temporal locality means current data or information that is being fetched may be needed soon. So we should
store that data or information in the cache memory so that we can avoid again searching in main memory for the
same data.

Spatial Locality
Spatial Locality means that all those instructions which are stored nearby to the recently executed instruction have
high chances of execution. It refers to the use of data elements (instructions) which are relatively close in storage
locations.

Question 3
In a multiprogramming and time-sharing environment, several users share the system simultaneously. What are
the possible problems in these environment w.r.t to data consistency, resource allocation and security
management?

Answer
In Multiprogramming and time sharing environment multiple users share the data and system so these are
following problems which might occur:

1. There can be the case of pilfering of data, which can result in various problems. It means after gaining
illegal access in somebody system and thieving the data is a problem
2. One more problem can be, “no proper accounting of resources”, it means if somebody is using the
resource without maintaining proper accounting data, is a serious problem.
3. We cannot assure same level of security as it is presented in dedicated machine. Because in time
sharing environment, multiple users are accessing the system, so it is somewhat difficult to implement
because if we are planning to use a high-level encryption for the sharing environment, than it will be
difficult to implement that security. Each and every security system made by human can be broken by
another human.

Question 4
Explain how Emulator is different from Virtualization? Why Java programs running on Android systems do not
use the standard Java API and virtual machine.

Answer
Difference between Emulator and Virtualization

The following are the key differences between emulation and virtualization.

1. The emulation process needs a software bridge, unlike virtualization. Whereas in virtualization, the
hardware would be accessed directly.
2. The major distinction between the virtual machine and the emulator is that the virtual machine directly
executes code with various domains in the language of use.
3. An interpreter is required for basic emulation. This interpreter translates the source code and then
translates it to the host system's readable format for further processing.
4. In an emulator, the guest operating system does not run-on physical hardware. In contrast to virtual
machines, emulators are sluggish. Emulators do not depend on the CPU while the VMs uses the CPU.
5. Virtualization physically places a layer between hardware, unlike emulation, to control and access it. As
virtualization allows us access to host resources, it helps in resource sharing between guest machines.

Why Java programs running on Android systems do not use the standard Java API and virtual
machine.

Instead of using the standard Java API. For JAVA development, google company has designed a separate Android
API. Android also uses the specially designed Dalvik virtual machine instead of the standard virtual machine or
JVM. In android, the java classes are first compiled to Java bytecode which is then translated into an executable
file to run on the Dalvik virtual machine. This Dalvik virtual machine is specially designed for Android which comes
optimized for mobile devices with limited memory and CPU processing capability. So, the Java programs running
on Android don't use the standard Java API or the virtual machine.

Question 5
Trap or exception is a software interrupt generated by the user program or by an error when the operating system
is needed by it to perform the system calls or an operation. Write a program in C++ that divide two integers, if
the divisor is zero than a trap or exception must be called. Program must throw an error and print the error message
on screen.
Answer

Output
Question 6
Interrupt is a signal emitted by hardware when a process or an event needs immediate attention. Write a program
in C++ that prints Hello World in an infinity loop. The loop must keep continues until a button is press by the
user. When user pressed a button, a signal or interrupt must be generated and handle the interrupt first.

Answer

Output

You might also like