0% found this document useful (0 votes)
9 views19 pages

Module 1 Os

The document discusses the roles and perspectives of operating systems, highlighting user and system views, multiprogramming, multitasking, operating system services, dual mode operation, process states, and process control blocks. It explains process creation and termination in UNIX, as well as the concept of virtual machines and their benefits. Overall, it provides a comprehensive overview of operating system functionalities and structures.

Uploaded by

Praveen Bandi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views19 pages

Module 1 Os

The document discusses the roles and perspectives of operating systems, highlighting user and system views, multiprogramming, multitasking, operating system services, dual mode operation, process states, and process control blocks. It explains process creation and termination in UNIX, as well as the concept of virtual machines and their benefits. Overall, it provides a comprehensive overview of operating system functionalities and structures.

Uploaded by

Praveen Bandi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

1)operating system and roles from different perspectives ?

An operating system is system software that acts as an intermediary between a user of a


computer and the computer hardware.
Operating System can be viewed from two viewpoints.
1) User views
2) System views

User Views: -it depends on the type of user.

• If the user is using standalone system, then OS is designed for ease of use
and high performances. Here resource utilization is not given importance.

• If the users are at different terminals connected to a mainframe or minicomputers,


by sharing information and resources, then the OS is designed to maximize
resource utilization. OS is designed such that the CPU time, memory and i/o are
used efficiently and no single user takes more than the resource allotted to them.

• If the users are in workstations, connected to networks and servers, then the
user have a system unit of their own and shares resources and files with other
systems. Here the OSis designed for both ease of use and resource availability
(files).

• Other systems like embedded systems used in home device (like washing m/c)
& automobiles do not have any user interaction. There are some LEDs to
show the status of its work
• Users of hand-held systems, expects the OS to be designed for ease of use and
performance per amount of battery life

System Views: - Operating system can be viewed as a resource allocator and control
program.

• Resource allocator – The OS acts as a manager of hardware and software


resources.
CPU time, memory space, file-storage space, I/O devices, shared files etc. are
the different resources required during execution of a program.
There can be conflicting request for these resources by different programs
running in same system.
The OS assigns the resources to the requesting program depending on the
priority.
• Control Program – The OS is a control program and manage the execution
of user program to prevent errors and improper use of the computer.
2)Multiprograming system?

Multiprogramming

One of the most important aspects of operating systems is the ability to multiprogram. A
single user cannot keep either the CPU or the I/O devices busy at all times.
Multiprogramming increases CPU utilization by organizing jobs, so that the CPU
always has one to execute.

Fig - Memory layout for a multiprogramming system

The operating system keeps several jobs in memory simultaneously as shown in


figure. This set of jobs is a subset of the jobs kept in the job pool. Since the number
of jobs that can be kept simultaneously in memory is usually smaller than the
number of jobs that can be kept in the job pool (in secondary memory).
The operating system picks and begins to execute one of the jobs in memory.
Eventually, the job may have to wait for some tasks, such as an I/O operation, to
complete. In a non-multiprogram system, the CPU would sit idle.
In a multiprogrammed system, the operating system simply switches to, and
executes, another job. When that job needs to wait, the CPU is switched to another
job, and so on.
Eventually, the first job finishes waiting and gets the CPU back. Thus, the CPU is
never idle.
Multiprogrammed systems provide an environment in which the various system
resources (for example, CPU, memory, and peripheral devices) are utilized
effectively, but they do not provide for user interaction with the computer system.
3)Time scheduling system and Multitasking ?
Multitasking Systems

In Time sharing (or multitasking) systems, a single CPU executes multiple jobs
by switching among them, but the switches occur so frequently that the users can
interact with each program while it is running. The user feels that all the programs
are being executed at the same time.
Time sharing requires an interactive (or hands-on) computer system, which
provides direct communication between the user and the system. The user gives
instructions to the operating system or to a program directly, using a input device
such as a keyboard or a mouse, and waits for immediate results on an output device.
Accordingly, the response time should be short— typically less than one second.
A time-shared operating system allows many users to share the computer
simultaneously. As the system switches rapidly from one user to the next, each user
is given the impression that the entire computer system is dedicated to his use only,
even though it is being shared among many users.
A multiprocessor system is a computer system having two or more CPUs within
a single computer system, each sharing main memory and peripherals. Multiple
programs are executed by multiple processors parallel.
4)op services ?

Operating-System Services

Q) List and explain the services provided by OS for the


user and efficient operation of system.

An operating system provides an environment for the execution of programs. It


provides certain services to programs and to the users of those programs.

OS provide services for the users of the system, including:

• User Interfaces - Means by which users can issue commands to the system.
Depending on the operating system these may be a command-line interface ( e.g.
sh, csh, ksh, tcsh, etc.), a Graphical User Interface (e.g. Windows, X-Windows,
KDE, Gnome, etc.), or a batch command systems.
In Command Line Interface (CLI)- commands are given to the system.
In Batch interface – commands and directives to control these commands are put
in a file and then the file is executed.
In GUI systems- windows with pointing device to get inputs and keyboard to enter
the text.
• Program Execution - The OS must be able to load a program into RAM, run the
program, and terminate the program, either normally or abnormally.
• I/O Operations - The OS is responsible for transferring data to and from I/O
devices, including keyboards, terminals, printers, and files. For specific devices,
special functions are provided (device drivers) by OS.
• File-System Manipulation – Programs need to read and write files or directories.
The services required to create or delete files, search for a file, list the contents of
a file and change the file permissions are provided by OS.
• Communications - Inter-process communications, IPC, either between processes
running on the same processor, or between processes running on separate
processors or separate machines. May be implemented by using the service of OS-
like shared memory or message passing.
• Error Detection - Both hardware and software errors must be detected and
handled appropriately by the OS. Errors may occur in the CPU and memory
hardware (such as power failure and memory error), in I/O devices (such as a
parity error on tape, a connection failure on a network, or lack of paper in the
printer), and in the user program (such as an arithmetic overflow, an attempt to
access an illegal memory location).

OS provide services for the efficient operation of the system, including:

• Resource Allocation – Resources like CPU cycles, main memory, storage space,
and I/O devices must be allocated to multiple users and multiple jobs at the same
time.
• Accounting – There are services in OS to keep track of system activity and
resource usage, either for billing purposes or for statistical record keeping that can
be used to optimize future performance.
• Protection and Security – The owners of information (file) in multiuser or
networked computer system may want to control the use of that information. When
several separate processes execute concurrently, one process should not interfere
with other or with OS. Protection involves ensuring that all access to system
resources is controlled. Security of the system from outsiders must also be done,
by means of a password.
5) Dual mode operation?
Explain dual mode operation in operating system with a neat block
diagramDual-Mode Operation
Since the operating system and the user programs share the hardware and software
resources of the computer system, it has to be made sure that an error in a user program
cannot cause problems to other programs and the Operating System running in the system.
The approach taken is to use a hardware support that allows us to differentiate among
various modes of execution.

The system can be assumed to work in two separate modes of operation:


1. User mode
2. Kernel mode (supervisor mode, system mode, or privileged mode).

A hardware bit of the computer, called the mode bit, is used to indicate the current
mode: kernel (0) or user (1). With the mode bit, we are able to distinguish between
a task that is executed by the operating system and one that is executed by the user.
When the computer system is executing a user application, the system is in user
mode. When a user application requests a service from the operating system (via a
system call), the transition from user to kernel mode takes place.

At system boot time, the hardware starts in kernel mode. The operating system is then
loaded and starts user applications in user mode. Whenever a trap or interrupt occurs, the
hardware switches from user mode to kernel mode (that is, changes the mode bit from 1
to 0). Thus, whenever the operating system gains control of the computer, it is in kernel
mode.
The dual mode of operation provides us with the means for protecting the operating
system from errant users—and errant users from one another.

The hardware allows privileged instructions to be executed only in kernel mode.


If an attempt is made to execute a privileged instruction in user mode, the hardware
does not execute the instruction but rather treats it as illegal and traps it to the
operating system. The instruction to switch to user mode is an example of a
privileged instruction.

Initial control is within the operating system, where instructions are executed in
kernel mode. When control is given to a user application, the mode is set to user
mode. Eventually, control is switched back to the operating system via an interrupt,
a trap, or a system call.
6)process states and process controller blocks?

Q)Illustrate with a neat sketch, the process states and process control block.
Process State
A Process has 5 states. Each process may be in one of the following states –

1. New - The process is in the stage of being created.


2. Ready - The process has all the resources it needs to run. It is waiting to
be assigned to the processor.
3. Running – Instructions are being executed.
4. Waiting - The process is waiting for some event to occur. For example, the
process may be waiting for keyboard input, disk access request, inter-process
messages, a timer to go off, or a child process to finish.
5. Terminated - The process has completed its execution.

Figure: Diagram of process state

Process Control Block

For each process there is a Process Control Block (PCB), which stores the process-
specific information as shown below –

• Process State – The state of the process may be new, ready, running, waiting, and
so on.
• Program counter – The counter indicates the address of the next instruction to be
executed for this process.
• CPU registers - The registers vary in number and type, depending on the computer
architecture. They include accumulators, index registers, stack pointers, and
general-purpose registers. Along with the program counter, this state information
must be saved when an interrupt occurs, to allow the process to be continued
correctly afterward.
• CPU scheduling information- This information includes a process priority,
pointers to scheduling queues, and any other scheduling parameters.
• Memory-management information – This includes information such as the value
of the base and limit registers, the page tables, or the segment tables.
• Accounting information – This information includes the amount of CPU and real
time used, time limits, account numbers, job or process numbers, and so on.
• I/O status information – This information includes the list of I/O devices
allocated to the process, a list of open files, and so on.

The PCB simply serves as the repository for any information that may vary from process
to process.

Figure: Process control block (PCB)


7)process creation and termination termination in unix?
Q)Demonstrate the operations of process creation and process termination in
UNIXProcess Creation
• A process may create several new processes. The creating process is called a
parent process, and the new processes are called the children of that process.
Each of these new processes may in turn create other processes. Every process
has a unique process ID.
• On typical Solaris systems, the process at the top of the tree is the ‘sched’
process with PID of 0. The ‘sched’ process creates several children processes
– init, pageout and fsflush. Pageout and fsflush are responsible for managing

memory and file systems. The init process with a PID of 1, serves as a parent
process for all user processes.
A process will need certain resources (CPU time, memory, files, I/O devices) to
accomplish its task. When a process creates a subprocess, the subprocess may be
able to obtain its resources in two ways:
directly from the operating system
Subprocess may take the resources of the parent
process. The resource can be taken from parent in
two ways –
▪ The parent may have to partition its resources among its children
▪ Share the resources among several children.
There are two options for the parent process after creating the child:

• Wait for the child process to terminate and then continue execution. The parent
makes a wait() system call.
• Run concurrently with the child, continuing to execute without waiting.

Two possibilities for the address space of the child relative to the parent:

• The child may be an exact duplicate of the parent, sharing the same program
and data segments in memory. Each will have their own PCB, including
program counter, registers, and PID. This is the behaviour of the fork system
call in UNIX.
• The child process may have a new program loaded into its address space, with
all new code and data segments. This is the behaviour of the spawn system
calls in Windows.

In UNIX OS, a child process can be created by fork() system call. The fork
system call, if successful, returns the PID of the child process to its parents and
returns a zero to the child process. If failure, it returns -1 to the parent. Process
IDs of current process or its direct parent can be accessed using the getpid( ) and
getppid( ) system calls respectively.

The parent waits for the child process to complete with the wait() system call.
When the child process completes, the parent process resumes and completes its
execution.

In windows the child process is created using the function createprocess( ). The
createprocess( ) returns 1, if the child is created and returns 0, if the child is not created.

Process Termination
• A process terminates when it finishes executing its last statement and asks the
operating system to delete it, by using the exit () system call. All of the resources
assigned to the process like memory, open files, and I/O buffers, are deallocated
by the operating system.
• A process can cause the termination of another process by using appropriate system
call. The parent process can terminate its child processes by knowing of the PID
of the child.
• A parent may terminate the execution of children for a variety of reasons, such as:
The child has exceeded its usage of the resources, it has been allocated.
The task assigned to the child is no longer required.
The parent is exiting, and the operating system terminates all the children.
This is called cascading termination.
8) Multithreded programing ,definition ,models,benefits?
Assignment
1}with neat dia, explain the concept of virtual machine?
Q) Demonstrate the concept of virtual machine with an example
• The fundamental idea behind a virtual machine is to abstract the hardware of a
single computer (the CPU, memory, disk drives, network interface cards, and so
forth) into several different execution environments, thereby creating the illusion
that each separate execution environment is running its own private computer.
• Creates an illusion that a process has its own processor with its own memory.
• Host OS is the main OS installed in system and the other OS installed in the system
are called guest OS.

Figure: System modes. (A) Non-virtual machine (b) Virtual machine


Virtual machines first appeared as the VM Operating System for IBM mainframes in 1972.

Implementation
• The virtual-machine concept is useful, it is difficult to implement.
• Work is required to provide an exact duplicate of the underlying machine.
Remember that the underlying machine has two modes: user mode and kernel
mode.
• The virtual-machine software can run in kernel mode, since it is the operating
system. The virtual machine itself can execute in only user mode.

Benefits
• Able to share the same hardware and run several different execution environments
(OS).
• Host system is protected from the virtual machines and the virtual machines are
protected from one another. A virus in guest OS, will corrupt that OS but will not
affect the other guest systems and host systems.
• Even though the virtual machines are separated from one another, software
resources can be shared among them. Two ways of sharing s/w resource for
communication are:
o To share a file system volume (part of memory).
o To develop a virtual communication network to communicate between the
virtual machines.
• The operating system runs on and controls the entire machine. Therefore, the
current system must be stopped and taken out of use while changes are made and
tested. This period is commonly called system development time. In virtual
machines such problem is eliminated. User programs are executed in one virtual
machine and system development is done in another environment.
• Multiple OS can be running on the developer’s system concurrently. This helps
in rapid porting and testing of programmer’s code in different environments.
System consolidation – two or more systems are made to run in a single system

Examples
VMware
The Java Virtual Machine
System Boot
Operating System Generation
2)what is system calls explain the different types of system call?

• System calls provides an interface to the services of the operating system. These
are generally written in C or C++, although some are written in assembly for
optimal performance.
• The below figure illustrates the sequence of system calls required to copy a file
content from one file (input file) to another file (output file).

The system calls can be categorized into six major categories:

1. Process Control
2. File management
3. Device management
4. Information management
5. Communications
6. Protection
Figure: Types of system calls
1. Process Control

• Process control system calls include end, abort, load, execute, create process,
terminate process, get/set process attributes, wait for time or event, signal event,
and allocate and free memory.
• Processes must be created, launched, monitored, paused, resumed, and eventually
stopped.
• When one process pauses or stops, then another must be launched or resumed
• Process attributes like process priority, max. allowable execution time etc. are
set and retrieved by OS.
• After creating the new process, the parent process may have to wait (wait time),
or wait for an event to occur (wait event). The process sends back a signal when
the event has occurred (signal event)

2. File Management

The file management functions of OS are –


• File management system calls include create file, delete file, open, close, read,
write, reposition, get file attributes, and set file attributes.
• After creating a file, the file is opened. Data is read or written to a file.

• The file pointer may need to be repositioned to a point.

• The file attributes like filename, file type, permissions, etc. are set and
retrieved using system calls.
• These operations may also be supported for directories as well as ordinary files.

3. Device Management

• Device management system calls include request device, release device,


read, write, reposition, get/set device attributes, and logically attach or
detach devices.
• When a process needs a resource, a request for resource is done. Then the
control is granted to the process. If requested resource is already attached
to some other process, the requesting process has to wait.
• In multiprogramming systems, after a process uses the device, it has to be
returned to OS, so that another process can use the device.
• Devices may be physical (e.g. disk drives ), or virtual / abstract ( e.g. files,
partitions, and RAM disks ).

4. Information Maintenance
• Information maintenance system calls include calls to get/set the time, date,
system data, and process, file, or device attributes.
• These system calls care used to transfer the information between user and the
OS. Information like current time & date, no. of current users, version no. of
OS, amount of free memory, disk space etc. are passed from OS to the user.
5. Communication
• Communication system calls
create/delete communication connection,
send/receive messages, transfer status information, and
attach/detach remote devices.
• The message passing model must support calls to:
o Identify a remote process and/or host with which to
communicate.
o Establish a connection between the two processes.
o Open and close the connection as needed.

o Transmit messages along the connection.


o Wait for incoming messages, in either a blocking or non-
blocking state.
o Delete the connection when no longer needed.
• The shared memory model must support calls to:
o Create and access memory that is shared amongst processes
(and threads. )
o Free up shared memory and/or dynamically allocate it as
needed.
• Message passing is simpler and easier, (particularly for inter-
computer communications), and is generally appropriate for small
amounts of data. It is easy to implement, but there are system calls
for each read and write process.
• Shared memory is faster, and is generally the better approach where
large amounts of data are to be shared. This model is difficult to
implement, and it consists of only few system calls.

6. Protection
• Protection provides mechanisms for controlling which users /
processes have access to which system resources.
• System calls allow the access mechanisms to be adjusted as needed,
and for non- privileged users to be granted elevated access
permissions under carefully controlled temporary circumstances.

You might also like