Professional Documents
Culture Documents
E-Notes
Operating System (22516) Ch-2 Services and components of Operating System Marks: 10
Open ( ) system call for most file systems, a program initializes access to a file in a file system using the open
system call. This allocates resources associated to the file (the file descriptor), and returns a handle that the
process will use to refer to that file.
1. Process and Job Control: A running program needs to be able to halt its execution either normally (end) or
abnormally (abort). If the program discovers an error in its input and wants to terminate abnormally, it may
also want to define an error level. A process or job executing one program may want to load and execute
another program. This allows the control card interpreter to execute program as directly by the control cards
of the user job. If we create a new job or process, we should able to control its execution. We may also want
to terminate a job or process that we created (terminate process). If we find that it is incorrect or no longer
needed we need waiting time to finish execution (wait time). Another set of system calls are helpful in
debugging a program.
Example of Process related system call:
End, Abort
Load, Execute
Create process, Terminate process
Ready process, Dispatch process
Suspend process, Resume process
Get process attributes, Set process attributes
Wait for Time
Wait event, Signal event
Change priority of process
2. File Management: We can identify several common system calls dealing with files. We first need to be able
to create and delete files such a system call requires the name of the file and perhaps some of its attributes.
Once the file is created, we need to open it and use it. We may also read, write and reposition. Finally we need
to close the file, indicating that we are no longer using it.
We may need these same sets of operations for directories it we have a directory structure in the file
system. In addition for either files or directories we need to be able to determine the values of various
attributes and perhaps reset them if necessary. File attributes include the file name, a file type, protection
codes, accounting information and so on. Two system calls get file attributes and set file attributes are
required for this function. Some operating systems provide many more calls, such as calls for file move and
copy.
Example of file related system call:
Create file, Delete file
Open a file, Close a file
Create directory
Read, Write, Reposition
Get file attributes, Set file attributes
Create a link
Change working directory
3. Device Management: Files can be thought of as abstract or virtual devices. Thus many of the system calls
for files are also needed for devices. If there are multiple users of the system however we must first request
the device to ensure that we have exclusive use of it. After we are finished with the device, we must release it.
These functions are similar to the open/close system calls for files.
Once, the device has been requested we can read, write and reposition the device just as with files. In
fact the similarity between input/output devices and files is so great that many operating systems merge the
two into a combined file/device structure. In this case input/output devices are identified by special file
names.
System call related to device management:
Request device, Release device
Read, Write, Reposition
Get device attributes, set device attributes
4. Information Maintenance: 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 of its jobs and processes and there are
system calls to access this information. Generally, there are also calls to reset it. (get process attributes and
set process attributes).
Information Maintenance related system call
Get Time or Date, Set Time or Date
Get system Data, Set system Data
Get process, File or Device attributes
Set process, File or Device attributes
5. Communication: There are two models of inter-process communication, the message-passing model and
the shared memory model.
Message-passing uses a common mailbox to pass messages between processes: In the message-
passing model, the communicating processes exchange messages with one another to transfer
information. Messages can be exchanged between the processes either directly or indirectly through a
common mailbox. Before communication can take place, a connection must be opened. The name of
the other communicator must be known, be it another process on the same system or a process on
another computer connected by a communications network. Each computer in a network has a host
name by which it is commonly known. A host also has a network identifier, such as an IP address.
Similarly, each process has a process name, and this name is translated into an identifier by which the
operating system can refer to the process. The get hostid and get processid system calls do this
translation. The identifiers are then passed to the general purpose open and close calls provided by
the file system or to specific open connection and close connection system calls, depending on the
system’s model of communication. The recipient process usually must give its permission for
communication to take place with an accept connection call. Most processes that will be receiving
connections are special-purpose daemons, which are systems programs provided for that purpose.
They execute a wait for connection call and are awakened when a connection is made. The source of
the communication, known as the client, and the receiving daemon, known as a server, then exchange
messages by using read message and write message system calls. The close connection call
terminates the communication.
Shared memory use certain system calls to create and gain access to regions of memory owned by
other processes. : The two processes exchange information by reading and writing in the shared data.
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. Recall that,
normally, the operating system tries to prevent one process from accessing another process’s
memory. Shared memory requires that two or more processes agree to remove this restriction. 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 for exchanging smaller amounts of data, because no conflicts need be avoided. It is
also easier to implement than is shared memory for inter-computer communication. Shared memory allows
maximum speed and convenience of communication, since it can be done at memory speeds when it takes
place within a computer. Problems exist, however, in the areas of protection and synchronization between the
processes sharing memory
Secondary-Storage Management:
Systems have several levels of storage, including primary storage, secondary storage and cache storage.
Instructions and data must be placed in primary storage or cache to be referenced by a running program.
Because main memory is too small to accommodate all data and programs, and its data are lost when power is
lost, the computer system must provide secondary storage to back up main memory. Secondary storage
consists of tapes, Disks, and other media designed to hold information that will eventually be accessed in
primary storage (primary, secondary, cache) is ordinarily divided into bytes or words consisting of a fixed
number of bytes. Each location in storage has an address; the set of all addresses available to a program is
called an address space. The three major activities of an operating system in regard to secondary storage
management are:
Managing the free space available on the secondary-storage device
Allocation of storage space when new files have to be written.
Scheduling the requests for memory access.
1. Process Management:
The operating system manages many kinds of activities ranging from user programs to system programs like
printer spooler, name servers, file server etc. Each of these activities is encapsulated in a process. A process
includes the complete execution context (code, data, PC, registers, OS resources in use etc.). The basic unit of
software that the operating system deals with in scheduling the work done by the processor is either a process
or a thread, depending on the operating system. It’s tempting to think of a process as an application, but that
gives an incomplete picture of how processes relate to the operating system and hardware. The application
you see (word processor or spreadsheet or game) is, indeed, a process, but that application may cause several
other processes to begin, for tasks like communications with other devices or other computers. There are also
numerous processes that run without giving you direct evidence that they ever exist. A process, then, is
software that performs some action and can be controlled by a user, by other applications or by the operating
system. It is processes, rather than applications, that the operating system controls and schedules for
execution by the CPU. In a single-tasking system, the schedule is straightforward. The operating system allows
the application to begin running, suspending the execution only long enough to deal with interrupts and user
input.
The five major activities of an operating system in regard to process management are
1. Creation and deletion of user and system processes.
2. Suspension and resumption of processes.
3. A mechanism for process synchronization.
4. A mechanism for process communication.
5. A mechanism for deadlock handling.
2. Main-Memory Management
Services provided under Memory Management are directed to keeping track of memory and allocating/de
allocating it to various processes. The OS keeps a list of free memory locations. Before a program is loaded in
the memory from the disk, this MM consults the free list, allocates the memory to the process, depending
upon the program size and updates the list of free memory. Primary-Memory or Main-Memory is a large array
of words or bytes. Each word or byte has its own address. Main-memory provides storage that can be access
directly by the CPU. That is to say for a program to be executed, it must in the main memory.
3. File Management
A file is a collected of related information defined by its creator. Computer can store files on the disk
(secondary storage), which provide long term storage. Some examples of storage media are magnetic tape,
magnetic disk and optical disk. Each of these media has its own properties like speed, capacity, and data
transfer rate and access methods. A file system normally organized into directories to ease their use. These
directories may contain files and other directions.
The five main major activities of an operating system in regard to file management are
1. The creation and deletion of files.
2. The creation and deletion of directions.
3. The support of primitives for manipulating files and directions.
4. The mapping of files onto secondary storage.
5. The backup of files on stable storage media.
5. Secondary-Storage Management
Systems have several levels of storage, including primary storage, secondary storage and cache storage.
Instructions and data must be placed in primary storage or cache to be referenced by a running program.
Because main memory is too small to accommodate all data and programs, and its data are lost when power is
lost, the computer system must provide secondary storage to back up main memory. Secondary storage
consists of tapes, disks, and other media designed to hold information that will eventually be accessed in
primary storage (primary, secondary, cache) is ordinarily divided into bytes or words consisting of a fixed
number of bytes. Each location in storage has an address; the set of all addresses available to a program is
called an address space.
The three major activities of an operating system in regard to secondary storage management are:
1. Managing the free space available on the secondary-storage device
2. Allocation of storage space when new files have to be written.
3. Scheduling the requests for memory access.
Q. What are the system tools are used in Linux? Explain two of them in details
User Management: As the administrator, it is your job to create and manage the accounts for all required
users. Linux comes with several tools for user management. User management includes everything from
creating a user to deleting a user on your system.
Following are the Linux command line tools for managing users and groups:
1. useradd.
2. usermod.
3. userdel.
Useradd: Creating New User: To add new users in Linux system we can use useradd command.
Syntax: useradd login_name
Example: useradd xyz
passwd Command: The passwd command is used to set up passwords for users.
Syntax: password user_name
Example: $ passwd vijay
Changing password for vijay:
(current) UNIX password: 123 45
Enter new UNIX password: abc@123
Retype new UNIX password: abc@123
passwd: password updated successfully
Usermod: Modifying Properties of User: The command usermod is used to modify the properties of an
existing user.
Syntax: usermod -c <'newName'> <oldName>
Userdel: Delete a user account: To delete a user account userdel command is used.
Syntax: userdel -r <userName>
Security Policy: Following are the best practices for securing linux os Keep System Updated: Always keep
system updated with latest releases patches, security fixes and kernel when it’s available.
$ yum updates
$yum check-update
Use Secure SSH: Telnet and rlogin protocols uses plain text, not encrypted format which is the security
breaches. SSH is a secure protocol that use encryption technology during communication with server. Never
login directly as root unless necessary. Use “sudo” to execute commands.
$ vi /etc/ssh/sshd_config
$ PermitRootLogin no #disable root login
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. The device nodes in the /dev directory provide access to the corresponding kernel devices
Udev is the device manager for the Linux 2.6 kernel that creates/removes device nodes in the /dev
directory dynamically. udev provides a persistent device naming system through the /dev directory,
making it easier to identify the device.
Performance Monitor: It is really very tough job for every System or Network administrator to monitor and
debug Linux System Performance problems every day.
top Command: Linux top command is a performance monitoring program which is used frequently by many
system administrators to monitor Linux performance and it is available under many Linux/Unix like operating
systems. The top command used to display all the running and active real-time processes in ordered list and
updates it regularly. It display CPU usage, Memory usage, Swap Memory, Cache Size, Buffer Size, Process PID,
User, Commands and much more. It also shows high memory and CPU utilization of a running processes.
The top command is much useful for system administrator to monitor and take correct action when
required.
$ top
vmstat: Linux vmstat command used to display statistics of virtual memory, kernerl threads, disks, system
processes, I/O blocks, interrupts, CPU activity and much more.
Task Scheduler: Crontab files can be used to automate backups, system maintenance and other repetitive
tasks. The syntax is powerful and flexible, so you can have a task run every fifteen minutes or at a specific
minute on a specific day every year.