0% found this document useful (0 votes)
64 views52 pages

Unit 2 OS

Uploaded by

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

Unit 2 OS

Uploaded by

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

Unit II

Services & components of Operating system

Marks:10
2.1 Operating-System Services
• OS provides an environment for the execution
of programs.
• Also provides certain services to programs and
to the users of those programs.
• Services are provided for the convenience of the
programmer , to make the programming task
easier.
• Services provided by OS differ from one OS to
another.
Figure 2.1 shows one view of the various operating-system
services and how they interrelate.
•The following are the services provided by the
operating system.
User Interface
Program Execution
I/O Operations
File-system manipulation
Communications
Error Detection
Resource Allocation
Accounting
Protection
User Interface:
• Almost all operating systems have a user interface (UI).
• 3 Forms of UI:
1)command-line interface (CLI): which uses text
commands and a method for entering them
2)batch interface: in which commands and directives to
control those commands are entered into files, and those
files are executed
3) graphical user interface (GUI) :the interface is a
window system with a pointing device to direct I/O,
choose from menus, and make selections and a keyboard
to enter text.

• Some OS provide two or all three of these variations


Program Execution:
• Operating system must be able to load a program
into memory and to run that program.
• The program must be able to end its execution, either
normally or abnormally.
I/O Operations:
• Running program may require I/O , which may
involve a file or an I/O Device.
• For efficiency and protection purposes, the users are
not able to control the I/O devices.
• So it is the duty of the OS to provide a means to
do I/O since users cannot execute them directly.
File-system manipulation
• Programs need to read and write files &
directories.
• Programs also need to create and delete files by
name.
• Also search the file, list its information.
• Some OS include permissions management to
allow or deny access to files or directories.
• The operating system handles the process of
creating, deleting and manipulating files.
Communications:
• Every process needs to exchange information with
another process.
• Communications occurs in two ways.
1. processes that are executing on the same computer.
2. processes that are executing on different computer.
• Communications may be implemented via shared
memory or by the technique of message passing.
• In shared memory, two or more processes read and
write to a shared section of memory,
• In Message Passing, which packets of information
in predefined formats are moved between processes
Error Detection:
• Errors can happen any time in the system.
• Errors can occur in the CPU ,memory hardware ,I/O
Devices ,and in the user program.
• For each type of error ,the operating system should
take the appropriate action to ensure correct and
consistent computing , by detecting the errors.
• Sometimes it might terminate an error-causing process
or return an error code to a process for the process to
detect and possibly correct.
Resource Allocation:
• When there are multiple users or multiple jobs running
at the same time, resources must be allocated to each of
them
• Many different types of resources are managed by the
operating system.
• Some have special allocation code, whereas others
have general request and release code.
• The operating systems have various routines for
different jobs in the system, for example CPU
scheduling
Accounting:
• We need to keep track of which users use how much
and what kind of computer resources.
• This tracking of user information can be used to find
out the usage statistics.
• These usage statistics are useful for the researchers
who wish to re-configure the system to improve
computing services.
Protection & Security:
• Protection and Security is an important issue in multi-
user computer systems.
• Protection involves in ensuring that all access to
system resources is controlled.
• Protection of the system from outside users is also
important.
• Access to the resources must be authenticated with a
password.
2.2 System Calls
• System call is interface between program and
Operating System.
• It is a programmatic method in which a computer
program requests a service from the OS.
• System call is a function provided by the kernel to
enter kernel mode to access the hardware resources
or services provided by OS.
• System call provides the services of the operating
system to the user programs via API.
• The Application Program Interface (API) connects the
operating system's functions to user programs.
• Written in high level language( c and c++)
• Example of System call:
• System call sequence to copy the contents
of one file to another file
• For example if we need to write a program code to read
data from one file, copy that data into another file. The
first information that the program requires is the name
of the two files, the input and output files.
• This type of program execution requires some system
calls by OS.
• First call is to write a prompting message on the screen
• Second, to read from the keyboard, the characters
which define the two files.
Why do you need system calls in Operating System?

• Following of the situations are as follows:


 It is must require when a file system wants to create or
delete a file.
 Network connections require the system calls to sending
and receiving data packets.
 If you want to read or write a file, you need to system
calls.
 If you want to access hardware devices, including a
printer, scanner, you need a system call.
 System calls are used to create and manage new
processes.
How System Call Works?
API – System Call – OS
Relationship
• A computer operates in two modes. They are user
mode and kernel mode.
• Some processes are running on a computer system.
A process is a program in execution. When application
programs are running, the computer is in user mode.
• If a hardware resource is required, the process sends
a request to the kernel, and the computer enters
kernel mode. These requests are sent using system
calls.
• The computer is switching between these two modes
frequently. When the task is completed, the computer
goes back to user mode from kernel mode. This mode
transition is known as “context switching.”
Standard C Library Example
⚫ C program invoking printf() library call, which calls write()
system call
System Call Parameter Passing
Three general methods used to pass parameters to the
OS
Simplest: pass the parameters in registers
In some cases, may be more parameters than registers
Parameters stored in a block, or table, in memory, and
address of block passed as a parameter in a register.
This approach taken by Linux and Solaris
Parameters placed, or pushed, onto the stack by the
program and popped off the stack by the operating
system
Block and stack methods do not limit the number or
Parameter Passing via
Table
Types of System Calls
• There are commonly five types of system calls.
These are as follows:
1. Process Control
2. File Management
3. Device Management
4. Information Maintenance
5. Communication
1. Process Control
• This system calls perform the task of process creation,
process termination, etc.
• A running program needs to be able to halt its execution
either normally (end()) or abnormally (abort()).
• A process or job executing one program may want to load()
and execute() another program.
• To create a new job or process (createprocess()).
• we should be able to control its execution. It requires the
ability to determine and reset the attributes of a job or
process, including the job’s priority, its maximum allowable
execution time, and so on (get process attributes() and set
process attributes()).
• We may also want to terminate a job or process that we
created (terminateprocess()) if we find that it is incorrect or is
no longer needed.
• Functions of Process Control:
• end, abort
• load, execute
• create process, terminate process
• get process attributes, set process
attributes
• wait for time
• wait event, signal event
• allocate and free memory
2. File Management
• File management system calls handle file
manipulation jobs like creating a file, reading, and
writing, etc.
• To create and to delete files (create() and delete().
• Once the file is created, we need to open() it and to
use it. We may also read(), write(), or reposition() .
• Finally, we need to close() the file, indicating that
we are no longer using it.
• File attributes include the file name, file type,
protection codes, accounting information . two
system calls, get file attributes() and set file
attributes(), are required
• Functions of File Management :
– Create a file
– Delete file
– Open and close file
– Read, write, and reposition
– Get file attributes and set file attributes
3. Device Management
• Device management does the job of device manipulation like
reading from device buffers, writing into device buffers, etc.
• A process may need several resources to execute like main
memory, disk drives, access to files, and so on. If the
resources are available, they can be granted, and control can
be returned to the user process.
• Resources are known as devices. Two types of devices are 1.
physical devices 2. virtual or logical devices
• Users may require to first request() a device, to ensure
exclusive use of it. After we are finished with the device, we
release() it.
• Once device is allocated, we can read(), write(), and
reposition() the device
• Functions of Device Management :
• request device, release device
• read, write, reposition
• get device attributes, set device
attributes
• logically attach or detach devices
4. Information Maintenance
• It handles information and its transfer between the
OS and the user program.
• To return the current time and date , system calls
time() and date() are used.
• To return information about the system, such as the
number of current users, the version number of the
OS, the amount of free memory or disk space, and
so on. get system data(), set system data() are used.
• OS keeps information about all its processes.
System calls used to reset the process information
get process attributes() and set process attributes()
are used
• Functions of Information Maintenance :
• Get or set time and date
• get system data, set system data
• Get process and device attributes
5. Communication
• These types of system calls are specially used for
interprocess communications.
• Two models of interprocess communication:
1. message passing model and
2. shared-memory model.
• In shared memory model, a shared memory region is
established which is used by the processes for data
communication. Processes use shared memory create()
and shared memory attach() system calls .
• In message-passing model, the processes communicate
with each other by exchanging message. Before
communication can take place, a connection must be
opened. Exchange messages by using read message() and
write message() system calls. The close connection() call
• Functions of Communication :
– Create, delete communications connections
– Send, receive message
– Help OS to transfer status information
– Attach or detach remote devices
Examples of Windows and Unix System Calls
2.3 Components of Operating System
• The components of an operating system are as
follows:
1. Process Management
2. Memory Management
3. Secondary Storage Management
4. I/O Management
5. File Management
6. Protection
7. Networking Management
8. Command Interpretation
1. Process Management
• The CPU executes a large number of programs.
• A process is a program in execution. A batch job is a
process. A time-shared user program is a process. A
system task, such as spooling, is also a process.
• The OS is responsible for the following activities in
connection with processes management:
1) The creation and deletion of both user and system
processes
2) The suspension and resumption of processes.
3) Provides synchronization mechanisms to control
concurrent access to shared data to keep shared data
consistent.
4) deadlock handling.
2. Memory Management
• Memory is a large array of words or bytes, each with its
own address.
• The task of subdividing the memory among different
processes is called memory management.
• The main aim of memory management is to achieve
efficient utilization of memory.
• The OS is responsible for the following activities in
connection with memory management:
1) Keep track of which parts of memory are currently
being used and by whom.
2) Decide which processes are to be loaded into
memory when memory space becomes available.
3) Allocate and deallocate memory space as needed
3. Secondary Storage or Disk Management
• The main memory is too small to permanently
accommodate all data and program, secondary storage
is used to backup main memory.
• Common types of secondary storage
1) magnetic storage devices, such as hard disk drives.
2) optical storage devices, such as CD, DVD and Blu-ray discs.
3) solid state storage devices, such as solid state drives and
USB memory sticks.
• The OS is responsible for the following activities in
connection with disk management:
1) Free space management
2) Storage allocation
3) Disk scheduling.
4. I/O Management
• OS need to manage the operations of various I/O
devices including mouse, keyboards, touch pad, disk
drives, USB devices, audio I/O, printers etc.
• The OS is responsible for the following activities in
connection with I/O management:
1) Hide the details of H/W devices
2) Manage main memory for the devices using
cache, buffer, and spooling
3) To activate a general device driver code
4) To run the driver software for specific hardware
devices as and when required.
5. File Management
• File management is one of the most visible services
of an operating system.
• Computers can store information in several different
physical forms; magnetic tape, disk are the most
common forms.
• The OS provides a uniform logical view of
information storage that is File.
• A file is a collection of related information defined by
its creator. Files represent programs and data.
• A files is a sequence of bits, bytes, lines or records
whose meaning is defined by its creator and user.
• Files are normally organized into directories
The OS is responsible for the following activities in
connection with File management:
1) File creation and deletion
2) Directory creation and deletion
3) The support of primitives for manipulating files
and directories.
4) The mapping of files onto disk storage.
5) Backup of files on stable (non volatile) storage.
6) Protection and security of the files.
6. Protection
• Various processes in an operating system must be
protected from each other’s activities.
• Various mechanisms can be used to ensure that the
files, memory segment, CPU and other resources can
be operated only on those processes that have
gained proper authorization from the operating
system.
• For example,
 memory addressing hardware ensures that a process can
only execute within its own address space.
 The timer ensures that no process can gain control of the
CPU without relinquishing it
• Protection refers to a mechanism for controlling the
access of programs, processes, or users to the
resources defined by a computer controls to be
imposed, together with some means of enforcement.
7. Networking Management
• Network management is the process of managing and
administering a computer network. A computer network is a
collection of various types of computers connected with
each other.
• Network management comprises fault analysis, maintaining
the quality of service, provisioning of networks, and
performance management.
• Network management is the process of keeping your
network healthy for an efficient communication between
different computers.
• Following are the features of network management:
1) Network administration
2) Network maintenance
3) Network operation
4) Network provisioning
8. Command Interpretation
• The command interpreter is the primary interface
between the user and the rest of the system.
• Command Interpreter System executes a user
command.
• Command Interpreter System allows users to interact
with the Operating System and provides convenient
programming environment to the users.
• A program which reads and interprets control
statements/commands is automatically executed.
• This program is variously called (1) the control card
interpreter, (2) the command line interpreter, (3) the
shell (Unix/Linux), and so on.
2.4 Use of Operating system tools
• Operating system is the mode in the computer that
turns the machine to a user enabled service.
• OS tools makes the user easy and comfortable
while using it
• Some tools are as
1. Computer Management
2. Device manager
3. Users and groups
4. Local security policy
5. Performance monitor
1. Computer Management:
• This tool found in Control Panel -> Administrative Tools -> Computer Management
• The administrative tools in Computer Management are grouped into the 3
categories :
1) System Tools:
• Event Viewer: Used to manage and view events that are recorded in the
Application, Security, and System logs.
• Shared Folders: Used to view connections and resource shared
• Local Users and Group: Creation, deletion of users and group
• Performance: Used to monitor and collect data about your computer's
performance.
• Device Manager: to view the hardware devices installed in your computer,
update device drivers, modify hardware settings, and troubleshoot device
conflicts.
• Task Scheduler: schedule a task to run a backup script every night, or send you
an e-mail whenever a certain system event occurs.
2) Storage:
• Removable Storage
• Disk Defragmenter
• Disk management : Disk Management helps you manage your hard
disks, and the partitions or volumes that they contain.
3) Services and Applications
• Services : to manage services on local and remote computers. You
can start, stop, pause, resume, or disable a service.
• WMI control :to configure and manage the Windows Management
Instrumentation (WMI) service.
2) Device manager :
• It is the responsibility of the operating system to keep track of
the status of all the devices in the computer system ,Device
manager does this.
• It allows users to view and control the hardware attached to
the computer.
• It can be used to control devices, enable or disable them,
configure them, identify conflicts between devices, and much
more.
• Device drivers are the software programs that are used by an
operating system to control the functioning of various devices
in a uniform manner .
• When an external hardware is connected to the computer,
then the device will be shown at the Device manager tray or
administrative window.
• computer detects the driver of the device and installation of
3) Users and Group:
• You can find this tool in Control Panel -> Administrative Tools ->
Computer Management->System Tools->User and Group
Or Go to the control panel -> 'user accounts‘ .
• User account can be created and the profile picture or password
can be managed easily.
• We can even have more user accounts enabled to operate at
different mode in the computer.
• We can give an access to the computer by making the guest
account enabled in a password protected computer.
• One administrator alone can have the access to view or manage
all other user's details.
• One user cannot see or access the files or settings of another user
until that user is set as administrator.
• Administrator alone can have the access to view or manage all
other user's details .
• Groups are logical expressions of organization, tying users
together for a common purpose. Users within the same group can
read, write, or execute files owned by the group.
• Each user and group has a unique numerical identification
number called a userid (UID) and a groupid (GID) respectively.
4. Local security policy
4. Local security policy

• You can find this tool in Control Panel ->


Administrative Tools -> Local security policy.
• The local security policy of a system is a set of
information about the security of a local
computer.
• It includes Account policy, Local Policy, Software
Restriction Policies, Application Control Policies.
• Allows administrator to provide access or deny
access to some users to some drive or software on
those drives. Thus the changes in those software
or drives will not be possible for them.
5. Performance manager
4. Local security policy

• You can find this tool in Control Panel ->


Administrative Tools -> Performance Monitor.
• You can use Performance Monitor to view
performance data.
• Administrators can use to examine how
programs running on their computers affect
the computer's performance.
• It shows real-time data about memory, network
adapter, physical disk, and processor usage.
• Used to monitor how the CPU is performing

You might also like