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

Operating System Module 1

Uploaded by

selzee040
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Operating System Module 1

Uploaded by

selzee040
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

ViewNotes

OPERATING SYSTEM
Module1
Solved Questions

1. Define an Operating System? What is the System’s view point of an Operating System?
Explain the dual mode Operation of an Operating System?

Ans : Definition:
An OS is a program that acts as an intermediary between computer-user and computer-hardware. It also
provides a basis for application-programs.
System’s view:
a) An Operating System as a resource allocator.
Resources used to solve a computing-problem:

→ CPU time
→ Memory-space
→ File-storage space and
→ I/0 devices.
The OS manages and allocates the above resources to programs and the users.

b) An OS is a control program. The OS is needed to control:


→ Operations of I/0 devices and
→ Execution of user-programs to prevent errors.
Dual Mode Operation:

Problem: We must be able to differentiate between the execution of OS code and user-defined code. Solution:
Most computers provide hardware-support.
• Two modes of operation : 1)User mode and 2) Kernel mode
• A mode bit is a bit added to the hardware of the computer to indicate the current mode : i.e. kernel (0) or
user (1) Transition from user to kernel mode .

Working principle:

i. At system boot time, the hardware starts in kernel-mode.


ii. The OS is then loaded and starts user applications in user-mode.

ViewNotes | Operating system (15CS64)


1
ViewNotes
iii. Whenever a trap or interrupt occurs, the hardware switches from user- mode to
kernel mode.
iv. The system always switches to user-mode before passing control to a user-
program.

Dual mode protects:

i. OS from errant users and


ii. Errant users from one another.

• Privileged instruction is executed only in kernel-mode.


• If an attempt is made to execute a privileged instruction in user-mode, the hardware treats it as illegal.
• A system calls are called by user-program to ask the OS to perform the tasks on behalf of the user program.

by user-program to ask the OS to perform the tasks on behalf of the user program.

ViewNotes | Operating system (15CS64)


2
ViewNotes

2. Distinguish between User-view and the System-view of an Operating System?

Ans: User View: The user's view of the computer depends on the interface being used:

 Most users use a PC consisting of a monitor, keyboard and system-unit.


 The OS is designed mostly for ease of use.
 Some attention is paid to performance.
 No attention is paid to resource utilization.
 The OS is optimized for the single-user experience.
 Some users use a terminal connected to a mainframe or (a minicomputer).
 The OS is designed: to maximize resource utilization.
 To assure that no individual user takes more than her fair share.
 Some users use a workstation connected to network.
 The users have dedicated resources such as networking and servers.
 The OS is designed to compromise between individual usability and resource
utilization.
 Some users use a handheld computer.
 The OS is designed mostly for individual usability.
 Performance per unit of battery life is a very important factor.

System View:

 An OS as a resource allocator.
 Resources used to solve a computing-problem:
1. CPU time
2. Memory-space
3. File-storage space and
4. I/0 devices.
 The OS manages and allocates the above resources to programs and the users.
 An OS is a control program The OS is needed to control:
 Operations of I/0 devices and
 Execution of user-programs to prevent errors.

ViewNotes | Operating system (15CS64)


3
ViewNotes

3. Explain Batch-Systems and Time-Shared-Systems?

Ans: Batch System:

Early computers were physically enormous machines run from a console.


The common input devices were card readers and tape drives.
The common output devices were line printers, tape drives, and card punches.
The user
 Prepared a job which consisted of the program, the data, and control
information.
 Submitted the job to the computer-operator.
 The job was usually in the form of punch cards.
 At some later time (after minutes, hours, or days), the output appeared.
 To speed up processing, operators batched together jobs with similar needs and ran them through the
computer as a group.
 Disadvantage: The CPU is often idle, because the speeds of the mechanical I/O devices.

Time Sharing Systems:

 Time sharing (or multitasking) is a logical extension of multiprogramming.


 The CPU executes multiple jobs by switching between them.
 Switching between jobs occur so frequently that the users can interact with each program while it is
running.
 Many users are allowed to share the computer simultaneously.
 CPU scheduling and multiprogramming are used to provide each user with a small portion of a
timeshared computer.
 To obtain a good response time, jobs may have to be swapped in and out of main memory to the disk
(called as backing store).
 Virtual memory is a technique that allows the execution of a job that may not be completely in memory.
 Advantage of virtual-memory: Programs can be larger than physical memory.

ViewNotes | Operating system (15CS64)


4
ViewNotes

 Main requirements:
 The system must provide a file-system.
 The system must provide disk-management.
 The system must provide CPU-scheduling to support concurrent execution.
 The system must provide job-synchronization to ensure orderly execution.

4. Differenciate between Multiprogramming and Multiprocessing ?

ViewNotes | Operating system (15CS64)


5
ViewNotes

5. Explain Multi-Programmed System?

Ans:

Multiprogramming increases CPU utilization by organizing jobs so that the CPU always has one to execute.
The idea is as follows:
 OS keeps several jobs in memory simultaneously .
 OS picks and begins to execute one of the jobs in the memory.
 Eventually, the job may have to wait for some task, such as an I/O
operation, to complete.
 OS simply switches to, and executes, another job.
 When that job needs to wait, the CPU is switched to another job, and so on.
 As long as at least one job needs to execute, the CPU is never idle.
 If several jobs are ready to be brought into memory, and if there is not enough room for all of them, then the system
must choose among them. Making this decision is job scheduling.
 If several jobs are ready to run at the same time, the system must choose among them. Making this decision is
CPU scheduling.
 Figure below : Memory layout for a multiprogramming system.

ViewNotes | Operating system (15CS64)


6
ViewNotes

6. Explain the memory-management of an Operating System?

Ans: Memory Management:

The OS is responsible for the following activities:

 Keeping track of which parts of memory are currently being used and by
whom.
 Deciding which processes are to be loaded into memory when
memory space becomes available.

 Allocating and de-allocating memory space as needed.

Main memory is the array of bytes ranging from hundreds to billions.

Each byte has its own address.

The CPU

 reads instructions from main memory during the instruction-fetch cycle.


 reads/writes data from/to main-memory during the data-fetch cycle.

To execute a program:

 The program will be loaded into memory and mapped to absolute


addresses.
 Then, program accesses instructions & data from memory by
generating absolute addresses.

 Finally, when program terminates, its memory-space is freed.

To improve CPU utilization, keep several programs will be kept in memory.

Selection of a memory-management scheme depends on hardware-design of the system.

ViewNotes | Operating system (15CS64)


7
[Type text]

7. Explain the activities for which operating system is responsible for connecting with the Process
management?

Ans: Process Management:

The OS is responsible for the following activities:


 Creating and deleting both user and system processes.
 Suspending and resuming processes.
 Providing mechanisms for process synchronization.
 Providing mechanisms for process communication.
 Providing mechanisms for deadlock handling
A process needs following resources to do a task:
 CPU, memory and files.
The resources are allocated to process when the process is created or while the process is running.
When the process terminates, the OS reclaims all the reusable resources.
A program by itself is not a process;
 A program is a passive entity (such as the contents of a file stored on disk).
 A process is an active entity.
 Two types of process: Single-threaded process has one PC(program counter) which specifies
location of the next instruction to be executed and Multi-threaded process has one PC per thread
which specifies location of next instruction to execute in each thread.

8. Explain the file management system in Operating System?

Ans: File System Management:

ViewNotes | Operating system (15CS64)


8
[Type text]

The OS is responsible for following activities:

 Creating and deleting files.

 Creating and deleting directories.

 Supporting primitives for manipulating files & directories.

 Mapping files onto secondary storage.

 Backing up files on stable (non-volatile) storage media.

Computer stores information on different types of physical media.

For ex: magnetic disk, optical disk.

Each medium is controlled by a device (e.g. disk drive).

The OS:

 Maps files onto physical media and accesses the files via the storage devices

File is a logical collection of related information.

File consists of both program & data.

Data files may be numeric, alphabets or binary.

When multiple users have access to files, access control (read, write) must be specified. 

9. Write a short note Distributed operating System?

Ans: Distributed System:

This is a collection of physically separate, possibly heterogeneous computer-systems.

The computer-systems are networked to provide the users with access to the various resources.

Access to a shared resource increases:

 computation

ViewNotes | Operating system (15CS64)


9
[Type text]
 speed
 functionality
 data availability and
 reliability

 A network is a communication path between two or more systems.

 Networks vary by the

 protocols used
 distances between nodes and
 transport media.
Common network protocol are
 TCP/IP → ATM.
Networks are characterized based on the distances between their nodes.
 A local-area network (LAN) connects computers within a building.
 A wide-area network (WAN) usually links buildings, cities, or
countries.
 A metropolitan-area network (MAN) could link buildings within a city.
The media to carry networks are equally varied.
They include copper wires, fiber strands, and wireless transmission.

10. Explain Multitasking Systems(Time Shared Systems)?

Ans: Time Sharing Systems:

Time sharing (or multitasking) is a logical extension of multiprogramming.


The CPU executes multiple jobs by switching between them.
Switching between jobs occur so frequently that the users can interact with
each program while it is running.
Many users are allowed to share the computer simultaneously.
CPU scheduling and multiprogramming are used to provide each user with a
small portion of a timeshared computer.
To obtain a good response time, jobs may have to be swapped in and out of
main memory to the disk (called as backing store).

ViewNotes | Operating system (15CS64)


10
[Type text]
Virtual memory is a technique that allows the execution of a job that may not
be completely in memory.
Advantage of virtual-memory: Programs can be larger than physical memory.
Main requirements:
 The system must provide a file-system.
 The system must provide disk-management.
 The system must provide CPU-scheduling to support concurrent
execution.
 The system must provide job-synchronization to ensure orderly
execution.

11. What are Virtual Machines? Explain the benefits of creating Virtual Machines?

12. What are Virtual Machines? Explain the Virtual Machine Architecture with a neat
diagram?

13. What are Virtual Machines? Explain how are they implemented?

Ans: Virtual Machines:

Main idea: To abstract hardware of a single computer into several different execution
environments.
An OS creates the illusion that a process has → own processor & → own (virtual) memory.
The virtual-machine provides
 An interface that is identical to the underlying hardware.
 A (virtual) copy of the underlying computer to each process.
Problem: Virtual-machine software itself will need substantial disk space to provide virtual
memory.
Solution: provide virtual disks that are identical in all respects except size.
Advantages:
 Complete protection of the various system resources.
 It is a perfect vehicle for OS‟s R&D.
Disadvantage:
 Difficult to implement due to effort required to provide an exact duplicate to underlying

ViewNotes | Operating system (15CS64)


11
[Type text]
machine.
Fig : System Models : a)Non virtual machine and b)Virtual machine

14. Define System calls ? Explain any two types of System calls ?
Ans: System Calls:

These provide an interface to the OS services.


These are available as routines written in C and C++.
The programmers design programs according to an API.
Types of System Calls : (5 types) :
 Process control.
 File management .
 Device management .
 Information maintenance .
 Communications.
i. File Management:
 System calls used:
 Create file, delete file.
 Open, close.
 read, write, reposition.
 get file attributes, set file attributes.
 Working procedure:
 We need to create and delete files.
 Once the file is created, we need to open it and to use it.
 we may also read or write.
 Finally, we need to close the file.
 We need to be able to determine the values of file-attributes and reset the file- attributes
if necessary.
 File attributes include file name ,file type ,protection codes and accounting

ViewNotes | Operating system (15CS64)


12
[Type text]
information.

ii. Communication:
 System calls used:
 Create, delete communication connection.
 Send, receive messages .
 Transfer status information.
 Attach or detach remote devices.
 Two models of communication:

 Message-passing model and


 Shared Memory Model

15. What are the different categories of the System programs? (Explain).

Ans: They provide a convenient environment for program development and execution.

(System program also called as System utilities).

They can be divided into 6 categories:


1. File Management:
These programs manipulate files i.e. create, delete, copy, and
rename files.
2. Status Information:
Some programs ask the system for date (or time) , amount of
memory(or disk space) or number of users.

These information is then printed to the terminal (or output- device


or file).

3. File Modification:
Text editors can be used to create and modify the content of files
stored on disk.
4. Programming Language Support:

ViewNotes | Operating system (15CS64)


13
[Type text]
 Compilers, assemblers, and interpreters for common
programming-languages (such as C, C++) are provided to the
user.


5. Program Loading & Execution:
The system may provide absolute loaders , re-locatable
loaders linkage editors and overlay loaders.

Debugging-systems are also needed.

6. Communications:
These programs are used for creating virtual connections between processes , users and computer-
systems. 
 They allow users to → browse web-pages 
→ send email or log-in remotely.
→ log-in remotely.

16. Differences between Direct and Indirect communication with respect to the Message-
parsing system?

Ans:
Direct Communication Indirect Communication
 Each process must explicitly name the  Messages are sent to/received from mailboxes
recipient/sender. (or ports).
 Symmetric addressing: Both sender and  Mailbox owned by a process: The owner can only
receiver processes must name the other to receive, and the user can only send. The mailbox
communicate. disappears when its owner process
terminates.
 Asymmetric addressing: Only the sender  Mailbox owned by the OS: The OS allows a
names the recipient and the recipient needn't name process to Create a new mailbox , Send & receive
the sender. messages via it and Delete a mailbox.

ViewNotes | Operating system (15CS64)


14
[Type text]
 Properties of a communication link:  Properties of a communication link:
 A link is established automatically  A link is established between a pair of
between every pair of processes that processes only if both members have a
want to communicate. shared mailbox.
 The processes need to know only each  A link may be associated with more
other’s identity to communicate. than two processes.
 A link is associated with exactly two  A number of different links may exist
processes. between each pair of communicating
 Exactly one link exists between each pair processes.
of processes.

ViewNotes | Operating system (15CS64)


15
[Type text]

17. With a neat diagram explain state transition of process?

Ans: Process State:

As a process executes, it changes state.

Each process may be in one of the following states (Figure below):


1. New: The process is being created.
2. Running: Instructions are being executed.
3. Waiting: The process is waiting for some event to occur (such
as I/0 completions).
4. Ready: The process is waiting to be assigned to a processor.
5. Terminated: The process has finished execution.

Only one process can be running on any processor at any instant.

Below figure represents the state transition diagram of process.

ViewNotes | Operating system (15CS64)


16
[Type text]

18. Explain PCB with a neat diagram ?

Ans: In OS, each process is represented by a PCB (Process Control Block).


PCB contains following information about the process (Figure):

1. Process State:

 The current state of process may be


→ new
→ ready
→ running
→ waiting or
→ halted.
2. Program Counter:
 This indicates the address of the next instruction to be executed for the process.

3. CPU Registers:

 These include :
→accumulators (AX)
→ index registers (SI, DI)
→ stack pointers (SP) and
→ general-purpose registers (BX, CX, DX).

4. CPU Scheduling Information:


 This includes
→ value of base- & limit-registers and
→ value of page-tables( or segment-tables).

5. Memory Management Information:


 This includes
→value of base- & limit-registers and
→ value of page-tables( or segment-tables).

ViewNotes | Operating system (15CS64)


17
[Type text]

6. Accounting Information:
 This includes :

→ amount of CPU time.


→ time-limit and
→ process-number.

7. I/O Status Information: This includes list of I/O devices and list of open files. Below
figure represents the PCB:

ViewNotes | Operating system (15CS64)


18
[Type text]

19. Explain
the
design → define goals and
goals of
→ define specifications.
the
Operatin
g → choice of hardware and
System? → type of system such as batch or time shared, and
single user or multiuser.
Ans: Design Goals:

• The first problem in


designing a system is
to :

• The design of the


system will be affected
by :
• Two basic groups of requirements:
• 1) User goals and 2) System goals
1. User Goals : The system should be:
→ convenient to use.
→ easy to learn and to use.
→ reliable, safe, and fast.
2. System Goals : The system should be :
→ easy to design and flexible.
→ implement, and maintain.

20. Explain the Inter-process communication and also about the advantages of process
being called as Co-operative process?

Ans: Processes executing concurrently in the OS may be:

1. Independent processes or
2. Co-operating processes.

ViewNotes | Operating system (15CS64)


19
`
1. A process is independent if :

 The process cannot affect or be affected by the other processes.

 The process does not share data with other processes.

2. A process is co-operating if :

 The process can affect or be affected by the other processes.

 The process shares data with other processes.

Advantages of process co-operation:

1. Information Sharing: Since many users may be interested in same


piece of information (ex: shared file).
2. Computation Speedup: We must break the task into subtasks. Each subtask
should be executed in parallel with the other subtasks.
The speed can be improved only if computer has
multiple processing elements such as CPUs or I/O channels.
3. Modularity: Divide the system-functions into separate processes or threads.
4. Convenience: An individual user may work on many tasks at the same time.

For example a user may be editing, printing, and compiling in parallel.

21. Explain Shared memory systems and Message passing (Two basic models of the IPC) ?
Ans: Shared-Memory
Communicating-processes must establish a region of shared-memory.

A shared-memory resides in address-space of the process creating the shared-memory. Other processes must attach their
address-space to the shared-memory.

The processes can then exchange information by reading and writing data in the shared-memory.

The processes are also responsible for ensuring that they are not writing to the same location simultaneously.

For example: Producer-Consumer Problem: Producer-process produces information that is consumed by a consumer-
process

Two types of buffers can be used:

1. Unbounded-Buffer places no practical limit on the size of the buffer.


2. Bounded-Buffer assumes that there is a fixed buffer-size.

Advantages:

ViewNotes | Operating system (15CS64)


20
`

 Allows maximum speed and convenience of communication.

 Faster.

Message-Passing

These allow processes to communicate and to synchronize their actions without sharing the same address- space.

For example, a chat program used on the WWW.

Messages can be of 2 types: 1) Fixed size or 2) Variable size.

If fixed-sized messages are used, the system-level implementation is simple. However, the programming task becomes
more difficult.

If variable-sized messages are used, the system-level implementation is complex. However, the programming task becomes
simpler.

A communication-link must exist between processes to communicate .

Three methods for implementing a link:


1. Direct or indirect communication.
2. Symmetric or asymmetric communication
3. Automatic or explicit buffering
4. 
Two operations:
1. send(P,message): Send a message to process P.
2. receive(Q,message): Receive a message from process Q.


Advantages:



 Useful for exchanging smaller amounts of data („.‟ No conflicts need be avoided).

 Easier to implement.

 Useful in a distributed environment.

ViewNotes | Operating system (15CS64)


21
`

 Useful for exchanging smaller amounts of data („.‟ No conflicts need be avoided).

 Easier to implement.

 Useful in a distributed environment.

ViewNotes | Operating system (15CS64)


22
ViewNotes

Figure : Communication models.

22. Explain two operations on process ?

23. Ans: Process Creation and Process Termination are the two operations on the process.

Process Creation:
A process may create a new process via a create-process system-call.
The creating process is called a parent-process. The new process created by the parent is called the child- process
(Sub-process).
OS identifies processes by p-id (process identifier), which is typically an integer-number.

ViewNotes | Operating system (15CS64)


23
ViewNotes


A process needs following resources to accomplish the task:
 CPU time
 memory and
 I/0 devices.
Child-process may get resources directly from the OS or get resources of parent-process.
This prevents any process from overloading the system.
Two options exist when a process creates a new process:
1) The parent & the children execute concurrently. 2) The parent waits until all the children have terminated.
Two options exist in terms of the address-space of the new process:
1. The child-process is a duplicate of the parent-process (it has the same program and data as the parent).
2. The child-process has a new program loaded into it.
Process Termination
A process terminates when it executes the last statement (in the program).
Then, the OS deletes the process by using exit() system-call.
Then, the OS de-allocates all the resources of the process.
The resources include :
 memory
 open files and
 I/0 buffers.
 Process termination can occur in following cases:
 A process can cause the termination of another process via TerminateProcess() system-call.
 Users could arbitrarily kill the processes.
 A parent terminates the execution of children for following reasons:

1. The child has exceeded its usage of some resources.


2. The task assigned to the child is no longer required.
3. The parent is exiting, and the OS does not allow a child to continue.
 In some systems, if a process terminates, then all its children must also be terminated. This phenomenon is referred to as
cascading termination.

ViewNotes | Operating system (15CS64)


24
ViewNotes

ViewNotes | Operating system (15CS64) 25

You might also like