Ch-1 Introduction to Operating System
Ch-1 Introduction to Operating System
Operating System :
An Operating System (OS) is an interface between a computer user and
computer hardware. An operating system is a software which performs all the
basic tasks like file management, memory management, process management,
handling input and output, and controlling peripheral devices such as disk drives
and printers.
1
Operating System Generations
Operating systems have been evolving over the years. We can categorise this
evaluation based on different generations which is briefed below:
0th Generation
The term 0th generation is used to refer to the period of development of computing
when Charles Babbage invented the Analytical Engine and later John Atanasoff
created a computer in 1940. The hardware component technology of this period
was electronic vacuum tubes. There was no Operating System available for this
generation computer and computer programs were written in machine language.
This computers in this generation were inefficient and dependent on the varying
competencies of the individual programmer as operators.
System operation was performed with the help of expert operators and without
the benefit of an operating system for a time though programs began to be written
in higher level, procedure-oriented languages, and thus the operator’s routine
expanded. Later mono-programmed operating system was developed, which
eliminated some of the human intervention in running job and provided
programmers with a number of desirable functions. These systems still continued
to operate under the control of a human operator who used to follow a number of
steps to execute a program. Programming language like FORTRAN was
developed by John W. Backus in 1956.
2
Researchers began to experiment with multiprogramming and multiprocessing in
their computing services called the time-sharing system. A noteworthy example
is the Compatible Time Sharing System (CTSS), developed at MIT during the
early 1960s.
The third generation officially began in April 1964 with IBM’s announcement of
its System/360 family of computers. Hardware technology began to use
integrated circuits (ICs) which yielded significant advantages in both speed and
economy.
3
Following are some of important functions of an operating System.
Memory Management
Processor Management
Device Management
File Management
Network Management
Security
Control over system performance
Job accounting
Error detecting aids
Coordination between other software and users
Memory Management
Main memory provides a fast storage that can be accessed directly by the CPU.
For a program to be executed, it must in the main memory. An Operating System
does the following activities for memory management −
Keeps tracks of primary memory, i.e., what part of it are in use by whom, what
part are not in use.
In multiprogramming, the OS decides which process will get memory when and
how much.
Allocates the memory when a process requests it to do so.
De-allocates the memory when a process no longer needs it or has been
terminated.
Processor Management
Keeps tracks of processor and status of process. The program responsible for this
task is known as traffic controller.
Allocates the processor (CPU) to a process.
De-allocates processor when a process is no longer required.
4
Device Management
Keeps tracks of all devices. Program responsible for this task is known as the I/O
controller.
Decides which process gets the device when and for how much time.
Allocates the device in the efficient way.
De-allocates devices.
File Management
A file system is normally organized into directories for easy navigation and usage.
These directories may contain files and other directions.
Keeps track of information, location, uses, status etc. The collective facilities are
often known as file system.
Decides who gets the resources.
Allocates the resources.
De-allocates the resources.
Advantages of NFS
CIFS is a Windows-based network for file sharing and is used in devices that
run on Windows OS. CIFS was introduced as the public version of Server
Message Block which was invented by Microsoft. This is a very efficient feature
that enables the devices to share multiple devices that are printers and even
multiple ports for the user and administration. CIFS also enables a request for
accessing files of another computer that is connected to the server. Then this
request is served by the server to the requested client. CIFS supports huge data
companies to ensure that their data is used by the employees at multiple
locations.
Advantages of CIFS
6
3. Wide OS Support: CIFS is ideal for networks that rely on Windows-based
systems.
Disadvantages of CIFS
User Interface (UI) Design shapes the user’s digital experience. From websites
to mobile apps, UI design encompasses the visual and interactive elements that
users engage with. A well-crafted UI not only enhances usability but also
communicates the brand’s identity and values. In this article, we delve into the
fundamentals of UI design, its importance, and the impact it has on user
engagement and satisfaction.
User Interface (UI) defines the way humans interact with the information
systems. In Layman’s terms, User Interface (UI) is a series of pages, screens,
buttons, forms, and other visual elements that are used to interact with the
device. Every app and every website has a user interface. User Interface (UI)
Design is the creation of graphics, illustrations, and the use of photographic
artwork and typography to enhance the display and layout of a digital product
within its various device views.
Interface elements consist of input controls (buttons, drop-down menus, data
fields), navigational components (search fields, slider, icons,
tags), and informational components (progress bars, notifications, message
boxes).
7
Types of UI Design
There are several types of User Interface (UI) depending upon the interaction
between users and computers or electronic devices in different ways. Some
common types of User Interface (UI) are:
Keep the interface simple: Clear and simple interface are best. Avoid
unnecessary elements. Best interfaces are invisible to user.
Be consistent and use common UI elements: Using common elements,
users feel more comfortable and are able to get things done more quickly.
Create pattern to facilitate efficiency.
Placement of items: To draw attention to most important pieces of
information careful placement of items is necessary. This can improve users
readability and engage them.
Use of right color: To direct attention towards something take advantage of
color, light, shade, contrast and texture. It’s important top make use of good
color combination as a bad color combination can easily distract or irritate a
user.
Anticipate: Make the user to work less by having pre-chosen fields, reduce
the burden on the user, and anticipate the goals of the users who come to
your site. The things which can be mostly searched by the users are presented
so that the users need not to work to search for it.
8
Advantages of UI Design
Though User Interface (UI) and User Experience (UX) are closely related
concepts in the field of software and website development, they differ in the
aspects of the overall user interaction with a product.
9
System Call
10
Features of System Calls
11
Operating system give control back to the program : After performing the
special operation, OS give control back to the program for further execution
of program.
12
Examples of a System Call in Windows and UNIX
System calls for Windows and UNIX come in many different forms. These are
listed in the table below as follows:
CreateProcess() Fork()
Process Control ExitProcess() Exit()
WaitForSingleObject() Wait()
Open()
CreateFile()
Read()
File manipulation ReadFile()
Write()
WriteFile()
Close()
SetConsoleMode() Ioctl()
Device Management ReadConsole() Read()
WriteConsole() Write()
GetCurrentProcessID() Getpid()
Information Maintenance SetTimer() Alarm()
Sleep() Sleep()
CreatePipe() Pipe()
Communication CreateFileMapping() Shmget()
MapViewOfFile() Mmap()
SetFileSecurity() Chmod()
Protection InitializeSecurityDescriptor() Umask()
SetSecurityDescriptorgroup() Chown()
Open(): Accessing a file on a file system is possible with the open() system call.
It gives the file resources it needs and a handle the process can use. A file can
be opened by multiple processes simultaneously or just one process. Everything
is based on the structure and file system.
Read(): Data from a file on the file system is retrieved using it. In general, it
accepts three arguments:
A description of a file.
A buffer for read data storage.
13
How many bytes should be read from the file
Before reading, the file to be read could be identified by its file descriptor
and opened using the open() function.
Wait(): In some systems, a process might need to hold off until another process
has finished running before continuing. When a parent process creates a child
process, the execution of the parent process is halted until the child process is
complete. The parent process is stopped using the wait() system call. The parent
process regains control once the child process has finished running.
Write(): Data from a user buffer is written using it to a device like a file. A
program can produce data in one way by using this system call. generally, there
are three arguments:
A description of a file.
A reference to the buffer where data is stored.
The amount of data that will be written from the buffer in bytes.
Fork(): The fork() system call is used by processes to create copies of
themselves. It is one of the methods used the most frequently in operating
systems to create processes. When a parent process creates a child process, the
parent process’s execution is suspended until the child process is finished. The
parent process regains control once the child process has finished running.
In many operating systems, the fork system call is an essential operation. The
fork system call allows the creation of a new process. When a process calls
the fork(), it duplicates itself, resulting in two processes running at the same
time. The new process that is created is called a child process. It is a copy of the
parent process. The fork system call is required for process creation and enables
many important features such as parallel processing, multitasking, and the
creation of complex process hierarchies.
It develops an entirely new process with a distinct execution setting. The
new process has its own address space, and memory, and is a perfect duplicate
of the caller process.
14
Basic Terminologies Used in Fork System Call in Operating System
Process Creation
When the fork system call is used, the operating system completely copies the
parent process to produce a new child process. The memory, open file
descriptors, and other pertinent properties of the parent process are passed down
to the child process. The child process, however, has a unique execution route
and PID.
The copy-on-write method is used by the fork system call to maximize memory
use. At first, the physical memory pages used by the parent and child processes
are the same. To avoid unintentional changes, a separate copy is made whenever
either process alters a shared memory page.
The return value of the fork call can be used by the parent to determine the
execution path of the child process. If it returns 0 then it is executing the child
process, if it returns -1 then there is some error; and if it returns some positive
value, then it is the PID of the child process.
15
Advantages of Fork System Call
Creating new processes with the fork system call facilitates the running of
several tasks concurrently within an operating system. The system’s
efficiency and multitasking skills are improved by this concurrency.
Code reuse: The child process inherits an exact duplicate of the parent
process, including every code segment, when the fork system call is used. By
using existing code, this feature encourages code reuse and streamlines the
creation of complicated programmes.
Memory Optimisation: When using the fork system call, the copy-on-write
method optimises the use of memory. Initial memory overhead is minimised
since parent and child processes share the same physical memory pages.
Only when a process changes a shared memory page, improving memory
efficiency, does copying take place.
Process isolation is achieved by giving each process started by the fork
system call its own memory area and set of resources. System stability and
security are improved because of this isolation, which prevents
processes from interfering with one another.
16
Disadvantages of Fork System Call
Memory Overhead: The fork system call has memory overhead even with
the copy-on-write optimisation. The parent process is first copied in its
entirety, including all of its memory, which increases memory use.
Duplication of Resources: When a process forks, the child
process duplicates all open file descriptors, network connections, and other
resources. This duplication may waste resources and perhaps result in
inefficiencies.
Communication complexity: The fork system call generates independent
processes that can need to coordinate and communicate with one another. To
enable data transmission across processes, interposes communication
methods, such as pipes or shared memory, must be built, which might add
complexity.
Impact on System Performance: Forking a process duplicates memory
allocation, resource management, and other system tasks. Performance of the
system may be affected by this, particularly in situations where processes are
often started and stopped.
17
Resource Management in Operating System
18
Features or characteristics of the Resource management of operating
system:
19
Semaphores
What is Semaphores?
When the value of the semaphore is zero, any process that performs a wait
operation will be blocked until another process performs a signal operation.
When a process performs a wait operation on a semaphore, the operation checks
whether the value of the semaphore is >0. If so, it decrements the value of the
semaphore and lets the process continue its execution; otherwise, it blocks the
process on the semaphore. A signal operation on a semaphore activates a process
blocked on the semaphore if any, or increments the value of the semaphore by
1. Due to these semantics, semaphores are also called counting semaphores. The
initial value of a semaphore determines how many processes can get past the
wait operation.
Semaphores are required for process synchronization to make sure that multiple
processes can safely share resources without interfering with each other. They
help control when a process can access a shared resource, preventing issues
like race conditions.
20
Types of Semaphores
Binary Semaphore: This is also known as a mutex lock, as they are locks
that provide mutual exclusion. It can have only two values – 0 and 1. Its value
is initialized to 1. It is used to implement the solution of critical section
problems with multiple processes and a single resource.
Counting Semaphore: Counting semaphores can be used to control access
to a given resource consisting of a finite number of instances. The semaphore
is initialized to the number of resources available. Its value can range over
an unrestricted domain.
To learn more refer: Types of Semaphores
Working of Semaphore
A semaphore is a simple yet powerful synchronization tool used to manage
access to shared resources in a system with multiple processes. It works by
maintaining a counter that controls access to a specific resource, ensuring that
no more than the allowed number of processes access the resource at the same
time.
There are two primary operations that a semaphore can perform:
1. Wait (P operation): This operation checks the semaphore’s value. If the
value is greater than 0, the process is allowed to continue, and the
semaphore’s value is decremented by 1. If the value is 0, the process is
blocked (waits) until the semaphore value becomes greater than 0.
2. Signal (V operation): After a process is done using the shared resource, it
performs the signal operation. This increments the semaphore’s value by 1,
potentially unblocking other waiting processes and allowing them to access
the resource.
21
Threats to Protection and Security
A threat is a program that is malicious in nature and leads to harmful effects for
the system. Some of the common threats that occur in a system are −
Virus
Viruses are generally small snippets of code embedded in a system. They are very
dangerous and can corrupt files, destroy data, crash systems etc. They can also
spread further by replicating themselves as required.
Trojan horse
A Trojan horse can secretly access the login details of a system. Then a malicious
user can use these to enter the system as a harmless being and wreak havoc.
Trap Door
A trap door is a security breach that may be present in a system without the
knowledge of the users. It can be exploited to harm the data or files in a system
by malicious people.
Worm
A worm can destroy a system by using its resources to extreme levels. It can
generate multiple copies which claim all the resources and don't allow any other
processes to access them. A worm can shut down a whole network in this way.
Denial of Service
These type of attacks do not allow the legitimate users to access a system. It
overwhelms the system with requests so it is overwhelmed and cannot work
properly for other user.
22
Protection and Security Methods
The different methods that may provide protect and security for different
computer systems are −
Authentication
This deals with identifying each user in the system and making sure they are who
they claim to be. The operating system makes sure that all the users are
authenticated before they access the system. The different ways to make sure that
the users are authentic are:
Username/ Password
Each user has a distinct username and password combination and they need to
enter it correctly before they can access the system.
User Key/ User Card
The users need to punch a card into the card slot or use they individual key on a
keypad to access the system.
User Attribute Identification
Different user attribute identifications that can be used are fingerprint, eye retina
etc. These are unique for each user and are compared with the existing samples
in the database. The user can only access the system if there is a match.
23
The operating system’s security and protection are discussed in this article. You
must understand the OS’s security and protection before we can talk about the
differences.
What is Security?
The security systems cover the safety of their system resources (saved data,
memory, disks, etc.) across malignant alteration, illegal access, and disparity or
inconsistency. The security gives a mechanism (authentication and encryption) to
analyse the user to permit for using the system. For example, in a corporation the
info is obtained by completely different workers however, it can’t be obtained by
a user that doesn’t exist in this explicit organization or a user operating in different
business enterprises. Security is a vital task for a corporation to provide some
safety mechanism so that no outside user will access the knowledge of the
organization.
What is Protection?
The protection deals with access to the system resources. It determines what files
can be accessed or permeated by a special user. The protection of the system
should confirm the approval of the process and users. Due to this, these licensed
users and processes will care for the central processing unit, memory, and
alternative sources. The protection mechanism ought to provide a path for
specifying the controls to be obligatory, besides how to implement them. An
example of protection can be given by security, any organization will have many
departments below which several staffs operate. The assorted departments will
share frequent info with one another but not sensitive info. So, completely
different employees have different access rights to the info in step with that they
will access the defined data.
24
Let’s see the difference between security and protection:
Security Protection
Security grants the system access to the While protection deals with access to
appropriate users only. the system resources.
Whereas in protection, an
In security, encryption and certification
authorization mechanism is
(authentication) mechanisms are used.
implemented.
In today’s tech world, multi-core and multi-processor systems have become
essential for boosting computing power and efficiency. A multicore system packs
several processing units or cores into a single chip allowing it to tackle multiple
tasks at once. Multiprocessor system uses two or more separate processors that
share resources enabling them to work together seamlessly. This means that if
one processor runs into trouble the others can keep things running smoothly. Both
systems are designed to meet the increasing demands of modern applications with
multicore systems focusing on maximizing performance within a single chip and
multiprocessor systems expanding capabilities through multiple CPUs.
25
What is a Multicore System?
A processor that has more than one core is called a Multicore Processor while one
with a single core is called Unicode Processor or Uniprocessor. Nowadays, most
systems have four cores (Quad-core) or eight cores (Octal-core). These cores can
individually read and execute program instructions, giving feel like a computer
system has several processors but in reality, they are cores and not processors.
Instructions can be calculation, data transferring instruction, branch instruction,
etc. Processors can run instructions on separate cores at the same time. This
increases the overall speed of program execution in the system. Thus heat
generated by the processor gets reduced and increases the overall speed of
execution.
Multicore systems support Multithreading and Parallel Computing. Multicore
processors are widely used across many application domains, including general-
purpose, embedded, network, digital signal processing (DSP), and graphics
(GPU). Efficient software algorithms should be used for the implementation of
cores to achieve higher performance. Software that can run parallel is preferred
because we want to achieve parallel execution with the help of multiple cores.
Dual-core processor do not work at twice speed of single processor. They get
only 60-80% more speed.
Some Operating systems are still using single core processor.
OS compiled for multi-core processor will run slightly slower on single-core
processor.
Two or more processors or CPUs present in same computer, sharing system bus,
memory and I/O is called MultiProcessing System. It allows parallel execution of
different processors. These systems are reliable since failure of any single
processor does not affect other processors. A quad-processor system can execute
26
four processes at a time while an octa-processor can execute eight processes at a
time. The memory and other resources may be shared or distributed among
processes.
It will have more traffic (distances between two will require longer time).
Throughput may get reduced in shared resources system where one processor
using some I/O then another processor has to wait for its turn.
As more than processors are working at particular instant of time. So,
coordination between these is very complex.
Difference between MultiCore and MultiProcessor System
MultiCore MultiProcessor
27
MultiCore MultiProcessor
28