Basics of OS
Basics of OS
Basics of OS
The Computer Hardware contains a central processing unit(CPU), the memory, and
the input/output (I/O) devices and it provides the basic computing resources for the
system.
The Application programs like spreadsheets, Web browsers, word processors,
etc. are used to define the ways in which these resources are used to solve the
computing problems of the users. And the System program mainly consists of
compilers, loaders, editors, OS, etc.
The Operating System is mainly used to control the hardware and coordinate its use
among the various application programs for the different users.
Basically, Computer System mainly consists of hardware, software, and data.
1. The operating system mainly controls the allocation and use of the computing
System’s resources among the various user and tasks.
2. It mainly provides an interface between the computer hardware and the programmer
that simplifies and makes feasible for coding, creation of application programs and
debugging
1. User's View
2. System View
The user view of the computer refers to the interface being used. Such systems are designed
for one user to monopolize its resources, to maximize the work that the user is performing. In
these cases, the operating system is designed mostly for ease of use, with some attention paid
to performance, and none paid to resource utilization.
The operating system can be viewed as a resource allocator also. A computer system consists
of many resources like - hardware and software - that must be managed efficiently. The
operating system acts as the manager of the resources, decides between conflicting requests,
controls the execution of programs, etc.
HISTORY OF OS:
Operating system was first developed in the late 1950’s to manage tape storage.
The general motors research lab implemented the first operating system in the early
1950’s for their IBM 701.
In the mid 1950’s , operating system started to use disks.
In the late 1950’s , the first version of the unix operating system was developed.
The first operating system built by Microsoft ws DOS. It was built in 1981 by
purchasing the 86 DOS software from a Seattle company.
The present day popular operating system windows first came into existence in 1985
when a GUI was created and paired with MS-DOS.
Examples of operating system:
Windows
Android
Ios
Mac os
Linux
Chrome os
Window phone os
1. Process management which involves putting the tasks into order and pairing them
into manageable size before they go to the CPU.
2. Memory management which coordinates data to and from RAM (random-access
memory) and determines the necessity for virtual memory.
3. Device management provides an interface between connected devices.
4. Storage management which directs permanent data storage.
5. An application that allows standard communication between software and your
computer.
6. The user interface allows you to communicate with your computer.
In this type of system, there is no direct interaction between user and the computer.
The user has to submit a job (written on cards or tape) to a computer operator.
Then computer operator places a batch of several jobs on an input device.
Jobs are batched together by type of languages and requirement.
Then a special program, the monitor, manages the execution of each program in the
batch.
The monitor is always in the main memory and available for execution.
Advantages:
Multiprogramming:
In this the operating system picks up and begins to execute one of the jobs from
memory.
Once this job needs an I/O operation operating system switches to another job (CPU
and OS always busy).
Jobs in the memory are always less than the number of jobs on disk(Job Pool).
If several jobs are ready to run at the same time, then the system chooses which one to
run through the process of CPU Scheduling.
In Non-multiprogrammed system, there are moments when CPU sits idle and does not
do any work.
In Multiprogramming system, CPU will never be idle and keeps on processing.
P1 P2 P3 P4 CPU
Multi tasking /Time Sharing:
Time Sharing Systems are very similar to Multiprogramming batch systems. In fact
time sharing systems are an extension of multiprogramming systems.
In Time sharing systems the prime focus is on minimizing the response time, while in
multiprogramming the prime focus is to maximize the CPU usage.
Multiprocessor Systems:
1. Enhanced performance
2. Execution of several tasks by different processors concurrently, increases the system's
throughput without speeding up the execution of a single task.
3. If possible, system divides task into many subtasks and then these subtasks can be
executed in parallel in different processors. Thereby speeding up the execution of
single tasks.
Network ooperating system:
Network operating system that run on a server and managing all the networking
functions.
Allow sharing various files , applications, printers , security and other networking
functions over a small network of computers like LAN or any other private network
Compute Server systems, provide an interface to which clients can send requests to
perform an action, in response to which they execute the action and send back results
to the client.
File Server systems, provide a file-system interface where clients can create, update,
read, and delete files.
Peer-to-Peer Systems
The growth of computer networks - especially the Internet and World Wide Web (WWW) –
has had a profound influence on the recent development of operating systems. When PCs
were introduced in the 1970s, they were designed for personal use and were generally
considered standalone computers. With the beginning of widespread public use of the
Internet in the 1990s for electronic mail and FTP, many PCs became connected to computer
networks.
In contrast to the Tightly Coupled systems, the computer networks used in these applications
consist of a collection of processors that do not share memory or a clock. Instead, each
processor has its own local memory. The processors communicate with one another through
various communication lines, such as high-speed buses or telephone lines. These systems are
usually referred to as loosely coupled systems ( or distributed systems). The general structure
of a client-server system is depicted in the figure below:
It is defined as an operating system known to give maximum time for each of the critical
operations that it performs, like OS calls and interrupt handling.
The Real-Time Operating system which guarantees the maximum time for critical operations
and complete them on time are referred to as Hard Real-Time Operating Systems.
While the real-time operating systems that can only guarantee a maximum of the time, i.e. the
critical task will get priority over other tasks, but no assurity of completeing it in a defined
time. These systems are referred to as Soft Real-Time Operating Systems.
Mobile /Handheld operating Systems:
Many handheld devices have between 512 KB and 8 MB of memory. As a result, the
operating system and applications must manage memory efficiently. This includes
returning all allocated memory back to the memory manager once the memory is no
longer being used.
Currently, many handheld devices do not use virtual memory techniques, thus
forcing program developers to work within the confines of limited physical memory.
Processors for most handheld devices often run at a fraction of the speed of a
processor in a PC. Faster processors require more power. To include a faster
processor in a handheld device would require a larger battery that would have to be
replaced more frequently.
The last issue confronting program designers for handheld devices is the small display
screens typically available. One approach for displaying the content in web pages
is web clipping, where only a small subset of a web page is delivered and displayed
on the handheld device.
Some handheld devices may use wireless technology such as BlueTooth, allowing remote
access to e-mail and web browsing. Cellular telephones with connectivity to the Internet fall
into this category. Their use continues to expand as network connections become more
available and other options such as cameras and MP3 players, expand their utility.
Clustered Systems:
Like parallel systems, clustered systems gather together multiple CPUs to accomplish
computational work.
Clustered systems differ from parallel systems, however, in that they are composed of
two or more individual systems coupled together.
The definition of the term clustered is not concrete; the general accepted definition is
that clustered computers share storage and are closely linked via LAN networking.
Clustering is usually performed to provide high availability.
A layer of cluster software runs on the cluster nodes. Each node can monitor one or
more of the others. If the monitored machine fails, the monitoring machine can take
ownership of its storage, and restart the application(s) that were running on the failed
machine. The failed machine can remain down, but the users and clients of the
application would only see a brief interruption of service.
Asymmetric Clustering - In this, one machine is in hot standby mode while the other
is running the applications. The hot standby host (machine) does nothing but monitor
the active server. If that server fails, the hot standby host becomes the active server.
Symmetric Clustering - In this, two or more hosts are running applications, and they
are monitoring each other. This mode is obviously more efficient, as it uses all of the
available hardware.
Parallel Clustering - Parallel clusters allow multiple hosts to access the same data on
the shared storage. Because most operating systems lack support for this simultaneous
data access by multiple hosts, parallel clusters are usually accomplished by special
versions of software and special releases of applications.
Clustered technology is rapidly changing. Clustered system's usage and it's features should
expand greatly as Storage Area Networks(SANs). SANs allow easy attachment of multiple
hosts to multiple storage units. Current clusters are usually limited to two or four hosts due to
the complexity of connecting the hosts to shared storage.
Each computer system includes a basic set of programs called the operating system. The most
and contains many critical procedures that are needed for the system to operate. The other
programs are called less utilities; they can provide a wide variety of interactive experiences
for the users as well as doing all the jobs the user bought the computer for, but the essential
shape and capabilities of the system are determined by the kernel.
The kernel provides key facilkitates to everything else on the system and determines many of
the characteristics of higher software.Hence, often use the operating system as a syncronym
for kernel.
Some operating systems allow all user programs to directly play with the hardware
components (a typical example is MS-DOS ). In contrast, a Unix-like operating system hides
all low-level details concerning the physical organization of the computer from applications
run by the user. When a program wants to use a hardware resource, it must issue a request to
the operating system. The kernel evaluates the request and, if it chooses to grant the resource,
interacts with the proper hardware components on behalf of the user program.
To enforce this mechanism, modern operating systems rely on the availability of specific
hardware features that forbid user programs to directly interact with low-level hardware
components or to access arbitrary memory locations. In particular, the hardware introduces at
least two different execution modes for the CPU: a nonprivileged mode for user programs
and a privileged mode for the kernel. Unix calls these User Mode and Kernel Mode ,
respectively.
The operating system helps to improve the efficiency of the work and helps to save a
lot of time by reducing the complexity.
The different components of a system are independent of each other, thus failure of
one component does not affect the functioning of another.
The operating system mainly acts as an interface between the hardware and the
software.
Users can easily access the hardware without writing large programs.
With the help of an Operating system, sharing data becomes easier with a large
number of users.
We can easily install any game or application on the Operating system easily and can
run them
An operating system can be refreshed easily from time to time without having any
problems.
An operating system can be updated easily.
There are various operating systems that are accessible in open source. Example:
Unix/Linux these can easily run on the personal computer with no cost that means
Free.
An operating system is mainly used to hide the complexity of the hardware.
AN operating system easily manages the computer as programming becomes easier.
With the help of an operating system, multitasking becomes easier.
Expensive There are some open-source platforms like Linux. But some operating
systems are expensive. Also, users can use free operating systems but generally, there
is a bit difficulty to run them than others. On the other hand, operating systems like
Microsoft Windows having GUI functionality and other in-built features are very
expensive.
Virus Threat Operating Systems are open to virus attacks and sometimes it happens
that many users download the malicious software packages on their system which
pauses the functioning of the Operating system and also slows it down.
Complexity Some operating systems are complex in nature because the language
used to establish them is not clear and well defined. If there occurs an issue in the
operating system then the user becomes unable to resolve that issue.
System Failure An operating system is the heart of the computer system if due to any
reason it will stop functioning then the whole system will crashes.
An Operating System provides services to both the users and to the programs.
It provides programs an environment to execute.
It provides users the services to execute the programs in a convenient manner.
One set of operating system provides functions that are helpful to the user
User interface
Program execution
I/O operations
File System manipulation
Communication
Error Detection
Another set of operating system functions exixtex not for helping the user but rather
for ensuring the efficient operation of thee system itself.Systems with multiple users
can gain efficiency by sharing the computer resources among the user
Resource Allocation
Accounting
Protection and security
User Interface:
Command line interface(CLI) uses text commands and a method for entering
them(KB for typing in commands in a specific format with specific options)
Another is a batch interface , in which commands and directives to control those
commands are entered into files, and those files are executed.
Most commonly, a graphical user interface is used.
Here, 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.
One systems provide two or all three of these variations.
Program execution:
Operating systems handle many kinds of activities from user programs to system
programs like printer spooler, name servers, file server, etc. Each of these activities is
encapsulated as a process.
A process includes the complete execution context (code to execute, data to
manipulate, registers, OS resources in use). Following are the major activities of an
operating system with respect to program management −
Loads a program into memory.
Executes the program.
Handles program's execution.
Provides a mechanism for process synchronization.
Provides a mechanism for process communication.
Provides a mechanism for deadlock handling.
I/O Operation
An I/O subsystem comprises of I/O devices and their corresponding driver software.
Drivers hide the peculiarities of specific hardware devices from the users.
An Operating System manages the communication between user and device drivers.
I/O operation means read or write operation with any file or any specific I/O device.
Operating system provides the access to the required I/O device when required.
I/O Operations:
A running program may require I/O, which may involve a file or an I/O device
For specific devices, special functions may be desired(such as recording a CD or
DVD device or blanking a display screen)
For efficiency and protection, users usually cannot control I/O devices directly.
Therefore the operating system must provide a means to do I/O.
A file represents a collection of related information. Computers can store files on the
disk (secondary storage), for long-term storage purpose. Examples of storage media
include magnetic tape, magnetic disk and optical disk drives like CD, DVD. Each of
these media has its own properties like speed, capacity, data transfer rate and data
access methods.
A file system is normally organized into directories for easy navigation and usage.
These directories may contain files and other directions. Following are the major
activities of an operating system with respect to file management −
Program needs to read a file or write a file.
The operating system gives the permission to the program for operation on file.
Permission varies from read-only, read-write, denied and so on.
Operating System provides an interface to the user to create/delete files.
Operating System provides an interface to the user to create/delete directories.
Operating System provides an interface to create the backup of file system.
Communication:
In case of distributed systems which are a collection of processors that do not share
memory, peripheral devices, or a clock, the operating system manages
communications between all the processes. Multiple processes communicate with one
another through communication lines in the network.
The OS handles routing and connection strategies, and the problems of contention and
security. Following are the major activities of an operating system with respect to
communication −
Two processes often require data to be transferred between them
Both the processes can be on one computer or on different computers, but are
connected through a computer network.
Communication may be implemented by two methods, either by Shared Memory or
by Message Passing.
Error Detection:
Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices
or in the memory hardware. Following are the major activities of an operating system
with respect to error handling −
The OS constantly checks for possible errors.
The OS takes an appropriate action to ensure correct and consistent computing.
Resource Management
In case of multi-user or multi-tasking environment, resources such as main memory,
CPU cycles and files storage are to be allocated to each user or job. Following are the
major activities of an operating system with respect to resource management −
The OS manages all kinds of resources using schedulers.
CPU scheduling algorithms are used for better utilization of CPU.
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 (Such as CPU cycles, main memory and file storage ) may have special
allocation code, whereas others(such as I/O devices) may have much more general
request and release code.
For instance , in determining how best to use the CPU , operating systems have
cpu scheduling routines that take into account the speed of the cpu , the jobs that
must be executed, the number of registers available and other factors.
There may also routines to allocate printers, modems, usb storage drives and other
periphera devices.
Accounting:
It keep track of which user use how much and what kind of computer resources.
This record keeping may be used for accounting or simply for accumulating usage
statistics may be a valuable tool for researchers who wish to reconfigure the system to
improve computing services.
The owners of information stored in a multi user or networked computer system may
want to control use of that information.
When several separate processes execute concurrently, it should not be possible for
one process to interfere with the others or with the operating system itself.
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 to the system, usually by means of password, go
gain access to system resources.
It extends to defending external I/O devices, including modems and network adapters,
from invalid access attempts and to recording all such connections for detection of
break-ins.
If a system is to be protected and secure, precautions must be instituted throughout it.
A system call is a method for a computer program to request a service from the kernel
of the operating system on which it is running. A system call is a method of
interacting with the operating system via programs. A system call is a request from
computer software to an operating system's kernel.
When a computer software needs to access the operating system's kernel, it makes a
system call. The system call uses an API to expose the operating system's services to
user programs. It is the only method to access the kernel system. All programs or
processes that require resources for execution must use system calls, as they serve as
an interface between the operating system and user programs.
Below are some examples of how a system call varies from a user function.
A system call function may create and use kernel processes to execute the
asynchronous processing.
A system call has greater authority than a standard subroutine. A system call with
kernel-mode privilege executes in the kernel protection domain.
System calls are not permitted to use shared libraries or any symbols that are not
present in the kernel protection domain.
The code and data for system calls are stored in global kernel memory.
How System Calls Work?
The Applications run in an area of memory known as user space. A system call
connects to the operating system's kernel, which executes in kernel space. When an
application creates a system call, it must first obtain permission from the kernel. It
achieves this using an interrupt request, which pauses the current process and
transfers control to the kernel.
If the request is permitted, the kernel performs the requested action, like creating or
deleting a file. As input, the application receives the kernel's output. The application
resumes the procedure after the input is received. When the operation is finished, the
kernel returns the results to the application and then moves data from kernel space to
user space in memory.
A simple system call may take few nanoseconds to provide the result, like retrieving
the system date and time. A more complicated system call, such as connecting to a
network device, may take a few seconds. Most operating systems launch a distinct
kernel thread for each system call to avoid bottlenecks. Modern operating systems are
multi-threaded, which means they can handle various system calls at the same time.
There are commonly five types of system calls. These are as follows:
Process Control
File Management
Device Management
Information Maintenance
Communication
Process Control
Process control is the system call that is used to direct the processes. Some process
control examples include creating, load, abort, end, execute, process, terminate the
process, etc.
File Management
File management is a system call that is used to handle the files. Some file
management examples include creating files, delete files, open, close, read, write, etc.
Device Management
Device management is a system call that is used to deal with devices. Some examples
of device management include read, device, write, get device attributes, release
device, etc.
Information Maintenance
Communication
Communication is a system call that is used for communication. There are some
examples of communication, including create, delete communication connections,
send, receive messages, etc.
Examples of Windows and Unix system calls
There are various examples of Windows and Unix system calls. These are as listed
below in the table:
open():
The open() system call allows you to access a file on a file system. It allocates
resources to the file and provides a handle that the process may refer to. Many
processes can open a file at once or by a single process only. It's all based on the file
system and structure.
read():
It is used to obtain data from a file on the file system. It accepts three arguments in
general:
A file descriptor.
A buffer to store read data.
The number of bytes to read from the file.
The file descriptor of the file to be read could be used to identify it and open it
using open() before reading.
wait():
In some systems, a process may have to wait for another process to complete its
execution before proceeding. When a parent process makes a child process, the parent
process execution is suspended until the child process is finished. The wait() system
call is used to suspend the parent process. Once the child process has completed its
execution, control is returned to the parent process.
write():
It is used to write data from a user buffer to a device like a file. This system call is one
way for a program to generate data. It takes three arguments in general:
A file descriptor.
A pointer to the buffer in which data is saved.
The number of bytes to be written from the buffer.
fork():
Processes generate clones of themselves using the fork() system call. It is one of the
most common ways to create processes in operating systems. When a parent process
spawns a child process, execution of the parent process is interrupted until the child
process completes. Once the child process has completed its execution, control is
returned to the parent process.
close():
It is used to end file system access. When this system call is invoked, it signifies that
the program no longer requires the file, and the buffers are flushed, the file
information is altered, and the file resources are de-allocated as a result.
exec():
exit():
The exit() is a system call that is used to end program execution. This call indicates
that the thread execution is complete, which is especially useful in multi-threaded
environments. The operating system reclaims resources spent by the process
following the use of the exit() system function.
Process Concepts
A process is a program in execution which then forms the basis of all computation.
The process is not as same as program code but a lot more than it. A process is an
'active' entity as opposed to the program which is considered to be a 'passive' entity.
Attributes held by the process include hardware state, memory, CPU, etc.
Process memory is divided into four sections for efficient working :
The Text section is made up of the compiled program code, read in from non-volatile
storage when the program is launched.
The Data section is made up of the global and static variables, allocated and
initialized prior to executing the main.
The Heap is used for the dynamic memory allocation and is managed via calls to
new, delete, malloc, free, etc.
The Stack is used for local variables. Space on the stack is reserved for local variables
when they are declared.
1 New
This is the initial state when a process is first
started/created.
2 Ready
The process is waiting to be assigned to a processor.
Ready processes are waiting to have the processor
allocated to them by the operating system so that they can
run. Process may come into this state after New state or
while running it by but interrupted by the scheduler to
assign CPU to some other process.
3 Running
Once the process has been assigned to a processor by the
OS scheduler, the process state is set to running and the
processor executes its instructions.
4 Waiting
Process moves into the waiting state if it needs to wait for
a resource, such as waiting for user input, or waiting for a
file to become available.
5 Terminated or Exit
Once the process finishes its execution, or it is terminated
by the operating system, it is moved to the terminated state
where it waits to be removed from main memory.
There is a Process Control Block for each process, enclosing all the information about
the process. It is also known as the task control block. It is a data structure, which
contains the following:
Process State: It can be running, waiting, etc.
Process ID and the parent process ID.
CPU registers and Program Counter. Program Counter holds the address of the next
instruction to be executed for that process.
CPU Scheduling information: Such as priority information and pointers to scheduling
queues.
Memory Management information: For example, page tables or segment tables.
Accounting information: The User and kernel CPU time consumed, account numbers,
limits, etc.
I/O Status information: Devices allocated, open file tables, etc.
Process vs Program
Process Program
A process has a dynamic instance A Program has static code and static
of code and data data.
Basically, a process is the running On the other hand, the program is
instance of the code. the executable code.