Unit 02
Unit 02
References:
1. Operating System Concepts: Silberschatz, Abraham, Galvin, Peter B., Gagne,
Greg: 9780470128725: Amazon.com: Books.
2. Operating Systems: Internals and Design Principles” by William Stallings
3. Operating Systems: A Concept-Based Approach” by D M Dhamdhere
AVK 1
Operating System (22516) CM 5I Unit No. 2
Program execution. The 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 (indicating error).
I/O operations. A running program may require I/O, which may involve a file or an I/O
device. For efficiency and protection, users usually cannot control I/O devices directly.
Therefore, the operating system must provide a means to do I/O.
File-system manipulation. Programs need to read and write files and directories. They
also need to create and delete them by name, search for a given file, and list file
information. Some programs include permissions management to allow or deny access to
files or directories based on file ownership.
File system manipulation: - Programs may need to read and write data from and to the
files and directories. Operating system manages the secondary storage. User gives a
command for reading or writing to a file. Operating system makes it easier for user
programs to accomplish their task such as opening a file, saving a file and deleting a file
AVK 2
Operating System (22516) CM 5I Unit No. 2
from the storage disk. It also provides services for file permission management to allow
or deny access to files or directories based on file ownership
Communications Many time, one process needs to exchange information with another
process. Such communication may occur between processes that are executing on the
same computer or different computer systems tied together by a computer network.
Communications may be implemented via shared memory or message passing, in which
packets of information are moved between processes by the operating system.
Error detection. The operating system needs to be constantly aware of possible errors.
Errors may occur in the CPU and memory hardware (such as a memory error or a power
failure), in 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.
Debugging facilities can enhance the user's and programmer's abilities to use the system
efficiently.
For System view:
• 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. For instance, in determining how
best to use the CPU, operating systems have CPU-scheduling routines. There may
also be routines to allocate printers, modems, USB storage drives, and other
peripheral devices.
• Accounting. We want to keep track of which users use how much and what kinds of
computer resources. This record keeping may be used for accounting or simply for
accumulating usage statistics.
• Protection and security.
Protection involves ensuring that all access to system resources is controlled. Security of
the system from outsiders is also important. Such security starts with requiring each user
to authenticate himself or herself to the system, usually by means of a password, to gain
access to system resources.
AVK 3
Operating System (22516) CM 5I Unit No. 2
AVK 4
Operating System (22516) CM 5I Unit No. 2
1. Process Control
o end, abort
o load, execute
o create process, terminate process
° get process attributes, set process attributes
o wait for time
° wait event, signal event
o allocate and free memory
A running program needs to be able to halt its execution either normally (end) or
abnormally (abort). If a system call is made to terminate the currently running program
abnormally, a dump of memory is taken and an error message generated. The dump is
written to disk and may be examined by a debugger, to determine the cause of the error.
Under either normal or ab +normal circumstances, the operating system must transfer
control to the command interpreter. The command interpreter then reads the next
command.
A process or job executing one program may want to load and execute another program.
This feature allows the command interpreter to execute a program as directed by, a user
thus, we have effectively created a mechanism for one program to call another program.
If both programs execute concurrently, we have created a new job or process to be
multiprogrammed. For this purpose, a system call exist like create process or submit
job.
If we create a new job or process, we should be able to control its execution. This
control 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. For this
purpose, the system call get process attributes and set process attributes is used. If
..we want to terminate a job or process that we created, use terminate process system
call.
AVK 5
Operating System (22516) CM 5I Unit No. 2
After creating new jobs or processes, we may need to wait for them to finish their
execution. We may want to wait for a certain amount of time, use wait time system call;
If we want to wait for a specific event to occur, use wait event system call. The jobs or
processes should then signal when that event has occurred, use signal event system call.
2. File Management
o create file, delete file
o open, close
o read, write, reposition
° get file attributes, set file attributes
The following system calls are common when dealing with files. We first need system
calls, to create and delete files. System call requires the name of the file and its
attributes. Once the file is created, we need to open it and to use it. We may also read,
write, or reposition i.e. rewrite or skip to the end of the file. Finally, we need to close the
file.
We may need these same sets of operations for directories. In addition, for r files or
directories, we need to be able to determine the various attributes and to reset them if
necessary. File attributes include the file name, a file type, protection codes, accounting
information, and so on. For this function, the system calls are get file attribute and set
file attribute,
3. Device Management
o request device, release device
o read, write, reposition
o get device attributes, set device attributes
° logically attach or detach devices
A process may need several resources to execute—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. Otherwise, the process will have to wait until sufficient
resources are available.
The various resources i.e. devices controlled by the operating system. Some of these
devices are physical devices (for example, tapes), or virtual devices (for example, files).
If there are multiple users of the system, the system may first request the device to use.
AVK 6
Operating System (22516) CM 5I Unit No. 2
After we are finished with the device, we release it. Once the device has been requested,
we can read, write, and reposition the device,
4. Information Maintenance:
get time or date, set time or date
get system data, set system data
set process, file, or device attributes
set process, file, or device attributes
Many system calls exist simply for the purpose of transferring information between the
user program and the operating system. For example, most systems have a system call to
return the current time and date. Other system calls may return information about the
system, such as the number of current users, the version number of the operating system,
the amount of free memory or disk space, and so on.
In addition, the operating system keeps information about all its processes, and system
calls are used to access this information. Generally, calls are also used to reset the
process information (get process attributes and set process attributes).
5 Communication
° create, delete communication connection
o send, receive messages
o transfer status information
o attach or detach remote devices
AVK 7
Operating System (22516) CM 5I Unit No. 2
give its permission for communication with an accept connection system call. Most
processes that will be receiving connections execute a wait for connection system call.
Messages are exchanges between sources and receiving machines by using read message
and write message system calls. The close connection call terminates the
communication.
In the shared-memory model, processes use shared memory create and shared memory
attach system calls to create and gain access to regions of memory owned by other
processes. They can then exchange information by reading and writing data in the shared
areas. The form of the data and the location are determined by the processes and are not
under the operating system's control. The processes are also responsible for ensuring that
they are not writing to the same location simultaneously.
Message passing is useful when smaller amounts of data need to be exchanged because
conflicts needs be avoided. It is easy to implement than shared memory for
intercomputer communication. Shared memory allows maximum speed and convenience
of communication.
Components of operating system: The following are the system components.
1. Process Management
2. Main memory Management
3. File Management
4. I/O System management
5. Secondary Storage Management
Process Management: Process is current activity shown by a program counter. A
process can be a Program in execution. A process needs certain resources like CPU time,
memory, files and I/O devices to do its task. These resources are given to the process
when it is created or allocated to it when it is running. Process generally included a
process stack. The process is executed sequentially. The CPU executes instruction one
at a time. The operating system is responsible for the following activities in concern with
process management:
∑ Creating and deleting both user and system process
∑ Suspending and resuming processes
∑ Providing mechanism for process synchronization
AVK 8
Operating System (22516) CM 5I Unit No. 2
AVK 9
Operating System (22516) CM 5I Unit No. 2
lost when power is lost. Most modern computers use disks, as a on-line storage media.
Hence proper management of disk storage is of central importance to a computer system.
The operating system is responsible for the following activities, in concern with
secondary storage management:
∑ Free space management
∑ Storage allocation
∑ Storage De - allocation
∑ Disk Scheduling
2.4 Use of Operating System tools
Following are the operating tools:
User Management
Security policy
Device Management
Performance Monitor
Task Scheduler
Linux Based :
A) User management:
User accounts provide interactive access to the system for users and groups of
users. And usually have limited access to critical system files and directories.
The following commands are available on majority of Unix systems to create and
manage user accounts:
useradd, userdel, usermod, passwds. These are mostly used by the
administrators.
/etc/passwd − Keeps the user account and password information. This file holds
the majority of information about accounts on the Unix system.
ß /etc/passwd – User account information.
ß /etc/shadow – Secure account information.
ß /etc/group – Group account information.
ß /etc/gshadow – Secure group account information.
Create an account:
Useradd: Adds accounts to the system.
Syntax: useradd -d homedir -g groupname -m -s shell -u userid accountname
AVK 11
Operating System (22516) CM 5I Unit No. 2
-d homedir
1
Specifies home directory for the account
-g groupname
2
Specifies a group account for this account
-m
3
Creates the home directory if it doesn't exist
-s shell
4
Specifies the default shell for this account
-u userid
5
You can specify a user id for this account
accountname
6
Actual account name to be created
7
-c
Adds comment to the user account
If you do not specify any parameter, then the system makes use of the default values.
The useradd command modifies the /etc/passwd, /etc/shadow, and /etc/group files and
creates a home directory.
Delete an Account
Userdel: To delete a user account userdel command is used.
There is only one argument or option available for the command .r, for removing the
account's home directory and mail file
Syntax: userdel -r <userName>
Modify an Account
Usermod: The command usermod is used to modify the properties of
an existing user. It uses the same arguments as the useradd command, plus the -l
argument, which allows you to change the account name.
AVK 12
Operating System (22516) CM 5I Unit No. 2
For example, to change the account name mcmohd to mcmohd20 and to change home
directory accordingly, you will need to issue the following command −
$ usermod -d /home/mcmohd20 -m -l mcmohd mcmohd20
B) Device Management:
Device management is the process of managing the implementation, operation and
maintenance of a physical and/or virtual device. All Linux device files are located in the
/dev directory, which is an integral part of the root (/) filesystem because these device
files must be available to the operating system during the boot process.
Example: ls –l /dev
Above example gives the list of device file from kernel.
Udev is a device manager in Linux, supplies a dynamic device directory containing only
the nodes for devices which are connected to the system. It creates or removes the device
node files in the /dev directory.
C) Performance Monitor:
It is very tough job for every system or network administrator to monitor and debug
Linux System Performance problems every day. The commands discussed below are
some of the most fundamental commands when it comes to system analysis and
debugging Linux server issues such as:
1) vmstat: Virtual memory statistics
AVK 13
Operating System (22516) CM 5I Unit No. 2
AVK 14
Operating System (22516) CM 5I Unit No. 2
Computer management option can be found within the control panel of any computer
system. One may go to the control panel from the start menu. Within the control panel
there is Administrative tool. One of the administrative tools is computer management. On
the computer management window, one may find there are three panes. The left pane will
show some functions, and when one chooses a function from the left pane, the details of
the pane will be available at the pane at the centre, where as the right section will show
the series of action that can be taken. There is Task Scheduler within the system tools,
and even the windows event viewer can be also accessed from the computer management
list. One can also start defragmentation of the disk and disk spaces from here. And in the
performance sector, one can see how the system is performing and that can be observed
for a long period also.
User Management
Users and groups
One can easily go to the Users and groups pane from the tools. He or she has to go to the
control panel and there one they may find the tab, 'user accounts'. There is a User account
can be created and the profile picture or password can be managed easily. One can even
have numerous user accounts enabled to operate at different mode in the computer. Even
one can be given an access to the computer by making the guest account enabled in a
password protected computer. One user cannot see or access the files or settings of
another user until he or she is set as administrator. One administrator alone can have the
AVK 15
Operating System (22516) CM 5I Unit No. 2
access to view or manage all other user's details. There is yet another option in Users and
groups to function at the same time. The option is the group profile, where there will be a
group id and a group password, which can be accessed by the entire group.
Security policy
This is a feature for large corporate sector and is in the ultimate version of the Windows
Operating System. This feature will not be seen in the home computers. One can find the
local security under the Administrative tools, which one may get access from the control
panel. This option allows the 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, whom the access to change or configure it is given
by the administrator. By this end user policy, one administrator can allow or disallow any
user on those computers to get an access over few websites or not. By these the users can
also be restricted to surf freely at their workplace as most of the irrelevant website;
basically the irrelevant websites to the job will not be opened from there.
Device management
When an external hardware is connected to the computer, then the device will be shown
at the Device manager tray or administrative window. The hardware may be of various
types, like the printers, the USB ported devices like pen drive, a Tablet or a mobile, a
Mouse and a Keyboard or even a camera. Most of the time the computer detects the
driver of the device and installation of the driver is done instantly and automatically.
However, there are many devices which are to be installed separately, like the modems or
a networking device. And sometimes the device is to be added manually, from the add
device option in the device manager tool. Once the device is shown at the device manager
window, then the device can be configured or even troubleshooting of the device is also
applicable. One can go to the device manager pane from the tools directly or even can go
there via the control panel. At the category view in the control panel, one can find three
options to go to the Device manager window. The options are 'view devices and printers',
'add a device' and 'adjust commonly used mobility setting’'.
Performance monitor
It is the option to actually monitor how the CPU is performing. One can go there from the
control panel or another easy way to reach there is by pressing sticky keys on the key
boards. One can press Ctrl, Alt and Del at the same time, to find the option of Start Task
AVK 16
Operating System (22516) CM 5I Unit No. 2
Manager. User can go to the fourth tab under performance and there they can find two
graphs. One is showing the CPU Usage and the other showing Memory. One may find
that all the data are changing there randomly, which implicit the fact that those are the
live records of the usage and memory. One may find there in the small window a button
called Resource Monitor. By clicking there, a new larger window will open where there
will be four continuously running meters. The meters are of the CPU, Memory, Network
and Disk. Thus all the records are placed in front one's eye and thus making the
performance monitoring easy.
Task scheduler
Windows can perform a task at a scheduled time and scheduled date. Not only one time
does it work, but windows can do a particular task scheduled every day at a particular
time or at particular interval. One can find the task scheduler by going to the tools. From
tools, one has to go to the control panel. From control panel, he or she has to go to
administrative tools to find the task scheduler. In windows 7, windows vista or windows
8, one may find the task scheduler in an updated version. Thus it makes the windows user
equipped with the best scheduler and that also without the support of any other software.
AVK 17