0% found this document useful (0 votes)
12 views

Chap 4 - Operating System

Uploaded by

Joseph PERSONNE
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Chap 4 - Operating System

Uploaded by

Joseph PERSONNE
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Topic : OPERATING SYSTEM

OPERATING SYSTEMS
Class: Comp. Sc A/L By:
By NDANG George

Modern general-purpose computers, including personal computers and mainframes, have an operating
system to run other programs, such as application software. An operating system act as an intermediary
between the user of a computer and computer hardware. The purpose of an operating system is to provide an
environment in which a user can execute programs in a convenient and efficient manner. Operating systems
are present on almost all modern devices described as computers, from personal computers to mainframes,
as well as mobile computers such as PDAs and mobile phones.

CHAPTER OBJECTIVES
This chapter aims:
- Define Operating system, functions, history and Evolution
- To describe the services an operating system provides to users, processes, and other systems.
- To discuss the various ways of structuring an operating system.
- To explain some Operating system concept such as system call, kernel mode, deadlock, paging,
segmentation …
- To describe in detail some functions of operating systems such as process management, memory
management, device management, …
- To describe some examples of today’s operating systems and contrast Linux & Windows operating system

Table of Contents

I. INTRODUCTION TO OPERATING SYSTEM .......................................................... 2


II. OPERATNG SYSTEM INTERFACES ....................................................................... 4
II. SERVICES OF AN OS................................................................................................ 2
III. EVOLUTION OF OS .................................................................................................. 3
V. OPERATING SYSTEM CONCEPTS ......................................................................... 5
VI. TYPES OF OPERATING SYSTEMS ......................................................................... 6
VII. FUNCTIONS OF OPERATING SYSTEMS………………………….
VII. PROCESS MANAGEMENT....................................................................................... 8
VIII. DEADLOCK ............................................................................................................. 12
IX. MEMORY MANAGEMENT .................................................................................... 14
X. FILE MANAGEMENT ............................................................................................. 17
XI. DEVICE MANAGEMENT ....................................................................................... 18
XII. SECURITY MANAGEMENT .................................................................................. 19
XIII. EXAMPLES OF OS .................................................................................................. 20

By NDANG George Page 1


Topic : OPERATING SYSTEM

I. INTRODUCTION TO OPERATING SYSTEM


An OS is a collection of programs that controls the execution of
application programs and acts as an interface between the user of a
computer and the computer hardware. OS along with hardware,
application and other system software, and users constitute a
computer system. It is the most important part of any computer system.
At the simplest level, an operating system does two things:
1. It manages the hardware and software resources of the system.
These resources include such things as the processor, memory,
disk space and more
2. It acts as an interface between the user and the physical machine that is it provides a stable, consistent way
for applications to deal with the hardware without having to know all its details

An operating system provides services to programs and to the users of those programs.
- It provides programs an environment for the execution of programs. (interface)
- It provides users, services to execute the programs in a convenient manner. (services)

II. OPERATNG SYSTEM INTERFACES


Almost all operating systems have a user interface (UI). This interface can take several forms.

II.1 command-line interface (CLI)


With a command line interface the user interacts with the computer
by typing commands. An interaction with a computer using a
command line interface usually follows these two steps :
- The user types a command e.g. "dir".
- The computer carries out the command and displays its results.
Examples are: MS-DOS, BBC Micro

II.2 Menu-Driven Interface


the user interacts with the computer by selecting options from a
menu. A typical program will have many menus which the user can
access. Menus can be either full screen or pull-down. Pull-down
menus are accessed by selecting the menu from a menu bar. Pop-
up menus are activated by pressing a button on the mouse.

II.3 Batch interface


In which commands and directives to control those commands are entered into files, and those files are
executed.

By NDANG George Page 2


Topic : OPERATING SYSTEM

II.4 Graphical User Interface (GUI)


With a Graphical User Interface (GUI) the user interacts with the
computer by using a pointing device such as a mouse or trackball. The most
popular form of GUI is a Windows, Icon, Menu and Pointer (WIMP)
system. The important features of a WIMP system are :
1. Window: An area of the screen which is used to display a particular
program or piece of work. Many windows can be displayed on the screen at
the same time.
2. Icon: An informative picture / symbol displayed on the screen which
the user chooses to select an action.
3. Menu: A list of options which the user can pick from. Menus can be pull-down (selected from a menu bar
at the top of the screen) or pop-up (selected by pressing a mouse button). e.g.
4. Pointer: A symbol such as an arrow which is moved by a pointing device and can be used to select objects.
When you use a program such as a word processor that has a WIMP interface it is often the case that the
document you are creating looks exactly the same on the screen as it will when it is printed out. The program is
described as being WYSIWYG. This stands for “What You See Is What You Get”.
Some systems provide two or all three of these variations.
- Microsoft Windows is GUI with CLI “command” shell
- Apple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells available
- Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)

III. SERVICES OF AN OS
The common service provided by the operating system is listed below.
1. Program execution: Operating system loads a program into memory and executes the program. The
program must be able to end its execution, either normally or abnormally.
2. I/O operation: I/O means any file or any specific I/O device. Program may require any I/O device while
running. So operating system must provide the means to do I/O.
3. File system manipulation: Program needs to read a file or write a file. The operating system gives the
permission to the program for operation on file.
4. Communications: Data transfer between two processes is required for some time. The both processes are
on the one computer or on different computer but connected through computer network. Communication may
be implemented by two methods: Shared memory and Message passing.
5. Error detection: The operating system constantly needs to be aware of possible errors in CPU, in I/O
devices or in memory hardware. It should take the appropriate action to ensure correct and consistent
computing.
6. Resource allocation: Operating system manages different types of resources require special allocation
code, i.e. main memory, CPU cycles and file storage.

By NDANG George Page 3


Topic : OPERATING SYSTEM
7. Protection et Security: Protection involves ensuring that all access to system resources is controlled.
Security starts with each user having to authenticate to the system, usually by means of a password. External
I/O devices must be also protected from invalid access attempts.
8. Accounting - To keep track of which users use how much and what kinds of computer resources

IV- EVOLUTION OF OS
Historically operating systems have been tightly related to the computer architecture. Operating systems have
evolved through a number of distinct phases or generations which corresponds roughly to the decades.

III.1 First Generations (1945-1955): Vaccum tubes & Serial Processing


The earliest electronic digital computers had no operating systems. Machines of the time were so primitive
that programs were often entered one bit at time on rows of mechanical switches (plug boards & punched
cards). Programming languages were unknown (not even assembly languages).

III.2 Second Generation (1955 – 1965): Transistors & batch processing


By the early 1950's, The General Motors Research Laboratories implemented the first operating systems in
early 1950's for their IBM 701(IBSYS). The system of the 50's generally ran one job at a time. These were called
single-stream batch processing systems because programs and data were submitted in groups or batches. E.g:
FMS (Fortran Monitor System)

III.3 Third Generation (1965-1980): ICs and Multiprogramming


The systems of the 1960's were also batch processing systems, but they were able to take better advantage
of the computer's resources by running several jobs at once. So operating systems designers developed the
concept of multiprogramming in which several jobs are in main memory at once; a processor is switched from
job to job as needed to keep several jobs advancing while keeping the peripheral devices in use. Another feature
present in this generation was time-sharing technique, a variant of multiprogramming technique, in which each
user has an on-line (i.e., directly connected) terminal. Eg: DEC PDP-1 until PDP-11

By NDANG George Page 4


Topic : OPERATING SYSTEM

III.4 Fourth Generation (1980-now): LSI and PC


Microprocessor technology evolved to the point that it become possible to build desktop computers as
powerful as the mainframes of the 1970s. Two operating systems have dominated the personal computer scene:
MS-DOS, written by Microsoft, Inc. for the IBM PC and other machines using the Intel 8088 CPU and its
successors, and UNIX, which is dominant on the large personal computers using the Motorola 6899 CPU family.

V. OPERATING SYSTEM CONCEPTS

V.1 OS Kernel
The lowest level of any operating system is its kernel. This is the first layer of software loaded into memory
when a system boots or starts up. The kernel provides access to various common core services to all other
system and application programs. These services include, but are not limited to: disk access, memory
management, task scheduling, and access to other hardware devices.

V.2 Operating system modes


Many CPU modes can be implemented by an OS. But generally a CPU can be either in kernel mode or User
mode.
- In kernel mode, also called master, supervisor or privileged mode or state, etc, the CPU has instructions to
manage memory and how it can be accessed, plus the ability to access peripheral devices like disks and network
cards. The CPU can also switch itself from one running program to another. It is an unrestricted mode
- In user mode, access to memory is limited to only some memory locations, and access to peripheral devices is
denied. The ability to keep or relinquish the CPU is removed, and the CPU can be taken away from a program
at any time. Now, all programs will be run in user mode, and this prevents them from accessing the data in
other programs, as well as preventing the disk etc.

V.3 System program


System programs provide a convenient environment for program development and execution.
They can be divided into:
- File manipulation – create, delete, copy, rename, print, list etc.
- Status information – Display date, time, disk space, memory size, etc.
- File modification – Create and modify files using text editors.
- Programming language support – Compilers, assemblers, and interpreters.
- Program loading and execution – Loaders, linkers.
- Communications – remote login, send and receive messages.
Most users’ view of the operation system is defined by system programs, not the actual system calls.

V.4 System call

By NDANG George Page 5


Topic : OPERATING SYSTEM
a system call is how a program requests a service from an operating system's kernel that it does not
normally have permission to run. System calls provide the interface between a process and the operating
system. Application developers often do not have direct access to the system calls, but can access them
through an application programming interface (API). The functions that are included in the API invoke the
actual system calls

Types of System Calls


Six major categories, as outlined in Figure 2.8 and the following six subsections:

Type System calls


- End, abort
- Load, execute
- Create process, terminate process
Process control - Get process attributes, set process attributes
- Wait for time
- Wait event, signal event
- Allocate and free memory
- Create file, delete file
File Management - Open, close
- Read, write, reposition
- Get file attributes, set file attributes
- Request device, release device
Device Management - Read, write, reposition
- Get device attributes, set device attributes
- Locally attach or detach devices
- Get time or date, set time or date
Information maintenance - Get system date, set system date
- Get process, file or devices attributes
- Set process, file or devices attributes
- Create, delete communication connection
Communication - Send, receive messages
- Transfer status information
- Attach or detach remote devices

V.5 Interrupt
An interrupt in an interruption in the normal execution of the program. When the CPU is interrupt, then it stops
its current activities like execution of the program. And transfer the control to interrupting device to check the
interrupt. The three types of interrupts are
• software interrupts or trap (syscall) - invoked by software
• external interrupts - invoked by external devices
• exceptions - invoked by the processor when errors occur

Interrupt Handling

By NDANG George Page 6


Topic : OPERATING SYSTEM
The code that is installed at the target address for interrupts is called an interrupt handler. The first thing that it
has to do is save the state of the currently executing process. Then it calls a subprogram to deal with the specific
type of interrupt. When that subprogram returns, the interrupt handler restores the state of the process that was
executing when the interrupt occurred.

VI. TYPES OF OPERATING SYSTEMS


Following are few of the important types of operating system which are most commonly used.

VI.1 Real-time operating system (RTOS)


Abbreviated as RTOS, a real-time operating system or embedded operating system is a computer operating
system designed to handle events as they occur. Real Time System is used at those Places in which we Requires
higher and Timely Response. These Types of Systems are used in Reservation. They are also found and used in
robotics, communications, and have various military and government uses.

VI.2 Single-user, single task


As the name implies, this operating system is designed to manage the computer so that one user can effectively
do one thing at a time. The Palm OS for Palm handheld computers is a good example of a modern single-user,
single-task operating system.

VI.3 Single-user, multi-tasking


This is the type of operating system most people use on their desktop and laptop computers today. Microsoft's
Windows and Apple's MacOS platforms are both examples of operating systems that will let a single user have
several programs in operation at the same time.

VI.4 Multi-user
A multi-user operating system allows many different users to take advantage of the computer's resources
simultaneously. Unix, VMS and mainframe operating systems, such as MVS, are examples of multi-user
operating systems.
VI.5 Multiprocessing OS
Multiprogramming OS have two or more processors for a single running process. Processing takes place in
parallel and is also called parallel processing. Each processor works on different parts of the same task, or, on
two or more different tasks. Linux, UNIX and Windows 7 are examples of multiprocessing OS.

VI.6 Time sharing Operating System (multitasking)


They refer to term where multiple jobs are executed by the CPU simultaneously by switching between them.
Switches occur so frequently that the users may interact with each program while it is running.

VI.7 Distributed operating System

By NDANG George Page 7


Topic : OPERATING SYSTEM
Distributed means “data is stored and processed on multiples locations”. They manage a collection of
independent computers and make them appear to the users of the system as a single computer. Users are not
aware of multiplicity of machines. Access to remote resources is similar to access to local resources.

VI.8 Network operating System


Network Operating System (NOS) runs on a server and provides server the capability to manage data, users,
groups, security, applications, and other networking functions. The primary purpose of the network operating
system is to allow shared file and printer access among multiple computers in a network, typically a LAN, a
private network or to other networks. Examples of network operating systems are Microsoft Windows Server
2003, Microsoft Windows Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD.

VI.9 Embedded Operating System:


An embedded operating system refers to the operating system that is self-contained in the device and resident in
the read-only memory (ROM).

VII- FUNCTIONS OF OPERATING SYSTEM


The main functions of a modern operating system are as follows:
- Process Management: As a process manager, the operating system handles the creation and deletion of
processes, suspension and resumption of processes and scheduling and synchronization of processes.
- Memory Management: As a memory manager, the operating system handles the allocation and
deallocation of memory space as required by various programs.
- File Management: The OS is responsible for creation and deletion of files and directories. It also takes
care of other file-related activities such as organizing, storing, retrieving, naming, and protecting the files.
- Device Management: OS provides I/O subsystem between process and device driver. It handles the
device caches, buffers and interrupts. It also detects the device failures and notifies the same to the user.
- Security Management: The operating system protects system resources and information against
destruction and unauthorized use.
- User Interface: OS provides the interface between the user and the hardware. The user interface is the
layer that actually interacts with the computer operator. The interface consists of a set of commands or menus
through which a user communicates with a program.

VII. PROCESS MANAGEMENT


VII. 1 what is a process?
A process is a name given to a program instance that has been loaded into memory and managed by the
operating system. Shortly, a process is a program in execution. (Program = static file (image). Process =
executing program = program + execution state)

By NDANG George Page 8


Topic : OPERATING SYSTEM

VII.2 Process States


A Process in execution will have to pass through different stages:
• New: The process is being created.
• Ready: The process is ready to be assigned to the processor.
• Running: The Process is currently using CPU to execute its instruction is in this stage.
• Waiting: The process is waiting for signal from some other process.
• Terminated: The Process that finishes its execution will be terminated.

Steps followed in the Process execution:


•A Process when first created will be in new stage, then when it is waiting for CPU time in order to get
executed will in ready stage. In Ready stage Process will be waiting for CPU time in Ready Queue (A queue
where Process waits for the CPU).
• Once the CPU become free and process acquires it, Process will enter into Running stage where it will
execute its instructions. If during this stage any interrupt occurs then it will move back to ready stage and wait
for the scheduler dispatcher. If it has I/O operation then it will move to Waiting stage where it will perform I/O
operation and then move back to ready stage and waits for the scheduler dispatcher.
• After the process get executed it will terminate.
The change of the state of the process from one form to another is called context change and this course of
action is known as context switching.

Fig: Process states


VII.3 Thread
A thread (or lightweight) is a task that runs concurrently with other tasks within the same process.. A thread is
the simplest unit of a process. The single thread of control allows the process to perform only one task at a
time. Ex: a text editor where a user can either edit the text or perform any other task like printing the
document. In a multitasking operating system, a process may contain several threads, all running at the same
time inside the same process. Writing a program in which a process creates multiple threads is called
multithread programming.

VII.3 Process Scheduling


In a multiprogrammed system, at any given time, several processes will be competing for the CPU time. Thus, a
choice has to be made which process to allocate the CPU next. This procedure of determining the next process to

By NDANG George Page 9


Topic : OPERATING SYSTEM
be executed on the CPU is called process scheduling and the module of operating system that makes this
decision is called a scheduler.
VII.3.1 Preemptive and Non-preemptive Scheduling
Preemptive scheduling allows a process to be interrupted in the midst of its execution, taking the CPU away
and allocating it to another process. Nonpreemptive scheduling ensures that a process relinquishes control of
the CPU only when it finishes with its current CPU burst.
CPU-scheduling decisions may take place under the following four circumstances:
1. When a process switches from the running state to the waiting state (for example, as the result of an I/O
request,…).
2. When a process switches from the running state to the ready state (for example, when an interrupt occurs).
3. When a process switches from the waiting state to the ready state (for example, at completion of I/O, on a
semaphore, or for some other reason).
4. When a process terminates.
For situations 1 and 4, there is no choice in terms of scheduling. A new process (if one exists in the ready queue)
must be selected for execution.
There is a choice, however, for situations 2 and 3. When scheduling takes place only under circumstances 1 and
4, we say that the scheduling scheme is nonpreemptive or cooperative; otherwise, it is pre-emptive.

VII.3.2 Algorithm to select process to execute


The scheduler uses some scheduling procedure to carry out the selection of a process for execution. The
efficiency of each algorithm is judged according to the average waiting time & the average turnaround time.
• Burst time: It is the amount of time a process uses the CPU for a single time.
• Waiting time - amount of time a process has been waiting in the ready queue (waitingTime =
startTime – arrivalTime)
• Turnaround time - It’s the total time taken by the process between starting and the completion.
(turnaroundTime = burstTime + waitingTime = finishTime- arrivalTime)
1) First-Come-First-Served:
As the name suggests, in FCFS scheduling, the processes are executed in the order of their arrival in the ready
queue. To implement FCFS scheduling procedure, the ready queue is managed as a first-in first-out (FIFO)
queue. It is a nonpreemptive scheduling.
Example:
Process Arrival time Burst time Service Time Wait Time : Service Time -
Arrival Time
P0 0 5 0 0-0=0
P1 1 3 5 5-1=4
P2 2 8 8 8-2=6
P3 3 6 16 16 - 3 = 13
Average Wait Time: (0+4+6+13) / 4 = 5.55

By NDANG George Page 10


Topic : OPERATING SYSTEM

2) Round Robin:
Here each process is provided a fix time to execute called quantum or slice time. After this time has
elapsed, the process is preempted and added to the end of the ready queue and other process executes for
given time period. Context switching is used to save states of preempted processes.
Example: Quantum = 3

Process Arrival time Bust Time Wait Time : Service Time - Arrival Time
P0 0 5 (0-0) + (12-3) = 9
P1 1 3 (3-1) = 2
P2 2 8 (6-2) + (14-9) + (19-17) = 11
P3 3 6 (9-3) + (17-12) = 11

Average Wait Time: (9+2+11+11) / 4 = 8.25

3) Shortest-Job-First Scheduling, SJF

The idea behind the SJF algorithm is to pick the quickest fastest little job that needs to be done, get it out
of the way first, and then pick the next smallest fastest job to do next. (Technically this algorithm picks a
process based on the next shortest CPU burst, not the overall process time.). For example, the Gantt chart
below is based upon the following CPU burst times, (and the assumption that all jobs arrive at the same time.)
Process Arrival time Burst time Service Time Wait Time : Service Time -
Arrival Time
P0 0 5 0 0-0=0
P1 1 3 5 5-1=4
P2 2 8 14 14 - 2 = 12
P3 3 6 8 8-3=5

P3 P2

Average Wait Time: (0+4+12+5) / 4 = 5.250

4) Priority Scheduling
Each process is assigned a priority. Process with highest priority is to be executed first and so on. Processes with
same priority are executed on first come first serve basis. Priority can be decided based on memory requirements,
time requirements or any other resource requirement

By NDANG George Page 11


Topic : OPERATING SYSTEM

P0 P3 P1

5 11
Wait time of each process is following

Process Process Time = Service Time – Arrival Time


P0 0–0=0
P1 11 – 1 = 10
P2 14 – 2 = 12
P3 5–3=2
Average Wait Time: (0+10+12+2) / 4 = 6

5) Shortest-Remaining-Time (SRT) Scheduling


Shortest remaining time, also known as shortest remaining time first (SRTF), is the preemtive counterpart of
SJF and useful in time-sharing environment. The process with the smallest estimated run-time to completion is
run next, including new arrivals. It picks a process and lets it run for a maximum of some fixed time.
V.5 Critical Section
The key to preventing trouble involving shared storage is find some way to prohibit more than one process from
reading and writing the shared data simultaneously. The part of the program where the shared memory is
accessed is called the Critical Section or critical regions. The most common way to avoid race conditions is to
mark the critical sections of code that are accessing shared data and ensure that only one process is ever
executing code in the critical section at a given time. This property is called mutual exclusion.

VIII. DEADLOCK
VIII.1 Definition and examples of deadlock
Let’s consider the situation where there are two utility programs A and B that each want to copy a file from tape
to disk and print the file to printer
- A holds tape and disk, then requests for a printer
- B holds printer, then requests for tape and disk
- A tries to get ownership of the printer, but is told to wait for B to release it.
- B tries to get ownership of the tape, but is told to wait for A to release it.
None of the process will be able to print and the two processes will remain in deadlock.
A deadlock occurs when an every member of a set of processes is waiting for an event that can only be
caused by a member of the set.

Other examples of deadlocks

1) Bridge traffic can only be in one direction.

By NDANG George Page 12


Topic : OPERATING SYSTEM
• Each entrance of the bridge can be viewed as a resource.
• Starvation is possible (Processes wait indefinitely).

2) In the automotive world deadlocks are called gridlocks.


• The processes are the cars.
• The resources are the spaces occupied by the cars

VIII.2 Necessary Conditions


The following four conditions (Coffman; Havender) are necessary but not sufficient for deadlock. Repeat: They
are not sufficient.
1. Mutual exclusion: A resource can be assigned to at most one process at a time (no sharing).
2. Hold and wait: A processing holding a resource is permitted to request another.
3. No preemption: A process must release its resources; they cannot be taken away.
4. Circular wait: There must be a chain of processes such that each member of the chain is waiting for
a resource held by the next member of the chain.

VIII.3 Resource allocation graph


The deadlock conditions can be modelled using a directed graph called a resource allocation graph (RAG).
Below is the Resource Allocation Graph,
• The processes are circles.
• The resources are squares.
• An arc (directed line) from a process P to a resource R signifies
that process P has requested (but not yet been allocated)
resource R.
• An arc from a resource R to a process P indicates that process P
has been allocated resource R.
If the graph does not contain a cycle, then no deadlock exists. If the graph does contain a cycle, then a
deadlock might exist

an example of a no deadlock situation. an example of a deadlock situation

NB: The presence of a cycle in a RAG is a necessary and not a sufficient condition for the deadlock to occur. It

By NDANG George Page 13


Topic : OPERATING SYSTEM

VIII.4 Methods for Handling Deadlocks


Generally speaking there are three ways of handling deadlocks:
1. Deadlock prevention or avoidance - Do not allow the system to get into a deadlocked state.
2. Deadlock detection and recovery - Abort a process or preempt some resources when deadlocks are
detected.
3. The Ostrich Approach: sticks your head in the sand and ignores the problem. This approach can be quite
useful if you believe that they are rarest chances of deadlock occurrence.

IX. MEMORY MANAGEMENT


In addition to managing processes, the operating system also manages the primary memory of the computer. The
part of the operating system that handles this job is called the memory manager. The major tasks accomplished
by the memory manager so that all the processes function in harmony are as follows:
• Allocation and Relocation: Each process must have enough memory to execute.
• Protection and Sharing: A process should not run into the memory space of another process.

IX.1 Relocation
When a process is to be executed, it has to be loaded from the secondary
storage (like hard disk) to the main memory (RAM). This is called
process loading. Since, main memory is limited and other processes also
need it for their execution, an operating system swaps the two processes,
which is called swapping. Once the process is 'swapped out', it is
uncertain to predict when it will be 'swapped in' because of the number
of processes running concurrently

IX.2 Protection and Sharing


In multiprogrammed systems, as a number of processes may reside in the main memory at the same time, there is
a possibility that a user program during execution may access the memory location allocated either to other user
processes or to the operating system. It is the responsibility of the memory manager to protect the operating
system from being accessed by other processes and the processes from one another.

By NDANG George Page 14


Topic : OPERATING SYSTEM

IX.3 Memory Allocation


The main challenge of efficiently managing memory comes when a system has multiple processes running at the
same time. In such a case, the memory manager can allocate a portion of primary memory to each process for its
own use.
Different strategies are used to allocate space to processes competing for memory. Three of the most popular
are: best fit, first fit and worst fit.
• Best Fit: In this case, the memory manager places a process in the smallest block of unallocated memory
in which it will fit. For example, a process requests 12 KB of memory and the memory manager currently has a
list of unallocated blocks of 6 KB, 14 KB, 19 KB, 11 KB and 13 KB blocks. The best fit strategy will allocate
12 KB of the 13 KB block to the process.
• First Fit: The memory manager places the process in the first unallocated block that is large enough to
accommodate the process. Using the same example to fulfil 12 KB request, first fit will allocate 12 KB of the
14 KB block to the process.
• Worst Fit: The memory manager places the process in the largest block of unallocated memory available.
To furnish the 12 KB request again, worst fit will allocate 12 KB of the 19 KB block to the process, leaving a 7
KB block for future use.

Fig: Strategies for Memory Allocation


IX.4 Paging and segmentation
1) Paging
Paging is a memory management scheme that allows the processes to be stored non-contiguously in the
memory. The memory is divided into fixed size chunks called page frames. The operating system breaks the
address space of the program (the collection of addresses used by the program) into fixed size chunks called
pages, which are of same size as that of page frames. Generally, page size is of 4 KB. However, some systems
support even larger page sizes such as 8 KB and 4 MB. When a process is to be executed, its pages are loaded
into unallocated page frames (not necessarily contiguous).
The main advantage of paging is that it minimizes the problem of fragmentation since memory allocated
is always in fixed units and any free frame can be allocated to a process.

2) Segmentation
By NDANG George Page 15
Topic : OPERATING SYSTEM
Segmentation is a Memory Management technique in which memory is divided into variable sized chunks
which can be allocated to processes. Each chunk is called a segment. A table stores the information about all
such segments and is called Global Descriptor Table (GDT). A GDT entry is called Global Descriptor.
3) Difference between paging and segmentation:-
Paging and segmentation are closed relative to each other but they have following difference.
→ Paging divides the virtual memory in physical memory areas while the segmentation divides it logically.
→ Paging divides the memory in fixed length memory areas while segmentation divides into variable length
memory areas.
→ In segmentation a full logical portion of the process in loaded, but in paging information about page is
loaded.
→ The segments are large length as compare to page.
→ In segmentation memory is divided into segments through software and in paging the memory in divided
through hardware.

IX.5 Concept of Virtual Memory


IX.5.1 What is virtual memory
it is the capability of the OS that enables programs to address more memory locations than are actually
provided in main memory. It is a method of using the computer hard drive to provide extra memory for the
computer. Segments of memory are stored on the hard drive known as pages. When a segment of memory is
requested that is not in memory it is moved from the virtual memory to an actual memory address.
The operating system manages virtual address spaces and the assignment of real memory to virtual
memory. Address translation hardware in the CPU, often referred to as a memory management unit or MMU,
automatically translates virtual addresses to physical addresses. Virtual memory allows for very effective
multiprogramming and relieves the user from the unnecessarily tight constraints of main memory

Fig: illustration of the concept of virtual memory

IX.5.2 Page Faults

A page fault is an interrupt that occurs when a software program attempts to access an invalid page in memory.
A page fault occurs when a program cannot find a page that it’s looking for in the physical memory, which
means that the program would have to access the paging file (which resides on the hard disk) to retrieve the
desired page.

X. FILE MANAGEMENT

By NDANG George Page 16


Topic : OPERATING SYSTEM

X.1 Notion of file and file management system


File can be defined as a collection of related information recorded on secondary storage (e.g., disks).
Almost all information stored in a computer must be in a file. a location for storing files on your computer is
called a folder or a directory.
Attributes of A file
- Name–only information kept in human-readable form
- Identifier–unique tag (number) identifies file within file system
- Type–needed for systems that support different types
- Location–pointer to file location on device
- Size–current file size
- Protection–controls who can do reading, writing, executing
- Time, date, and user identification–data for protection, security,and usage monitoring
File structure
Four terms are use for files
- Field: A field is the basic element of data. An individual field contains a single value.
- Record: A record is a collection of related fields that can be treated as a unit by some application
program.
- Database: A database is a collection of related data.

File Operations
Any file system provides not only a means to store data organized as files, but a collection of functions
that can be performed on files. Typical operations include the following:
- Create: A new file is defined and positioned within the structure of files.
- Delete: A file is removed from the file structure and destroyed.
- Open: An existing file is declared to be "opened" by a process, allowing the process to
perform functions on the file.
- Close: The file is closed with respect to a process, so that the process no longer may perform
functions on the file, until the process opens the file again.
- Read: A process reads all or a portion of the data in a file.
- Write: A process updates a file, either by adding new data that expands the size of the file or
by changing the values of existing data items in the file.

File name & extension


A common technique for implementing file types is to include the type as part of the file name. The name
is split into two parts : a name and an extension. Following table gives the file type with usual extension
and function.

By NDANG George Page 17


Topic : OPERATING SYSTEM

Directory
Information about files is kept in the directory structure, which is maintained on the disk. A directory
is nothing but a named section of a storage device, such as hard disk, floppy disk. In other words, to
organize file on hard disk or floppy disk, these are divided into various segments (sections), called
directories. You can store any number of files in each directory. The directory helps to organise your
file in an efficient manner.

A file management system is that set of system software that provides services to users and applications in
the use of files. Following objectives for a file management system:
• To meet the data management needs and requirements of the user which include storage of data and
the ability to perform the aforementioned operations.
• To guarantee, to the extent possible, that the data in the file are valid.
• To optimize performance, both from the system point of view in terms of overall throughput.
• To provide I/O support for a variety of storage device types.
• To minimize or eliminate the potential for lost or destroyed data.
• To provide a standardized set of I/O interface routines to use processes.

X.2 What is a File system?


1) Definition
File system is a system for organizing directories and files, generally in terms of how it is implemented in the
disk operating system. While the memory manager is responsible for the maintenance of primary memory, the
file manager is responsible for the maintenance of the file system.

2) Example of file systems


a) Windows file systems
→ FAT (File Allocation Table): FAT file system is one of the most simple types of file systems. There exist
different types of FAT: FAT12, FAT16, FAT32. The number in FAT12, FAT16, FAT32 stands for the number
if bits used to enumerate file system block. This means that FAT12 may use up to 4096 different block
references, FAT16 - 65536 and FAT32 - 4294967296.
→ NTFS (New Technology File System): This is a default file system for disk partitions and the only file
system that is supported for disk partitions over 32GB.

By NDANG George Page 18


Topic : OPERATING SYSTEM
→ ReFS (Resilient File System):: ReFS is the latest development of Microsoft presently available for
Windows 8 Servers.
b) MacOS file systems
Apple Mac OS operating system applies HFS+ file system, an extension to their own HFS file system that was
used on old Macintosh computers. HFS+ file system is applied to Apple desktop products, including Mac
computers, iPhone, iPod, as well as Apple X Server products. Advanced server products also use Apple Xsan
file system, clustered file system derived from StorNext or CentraVision file systems.

c) Linux file systems


Among huge amount of various file system types the most popular Linux file systems nowadays are:
→ Ext2, Ext3, Ext4 - 'native' Linux file system. This file system falls under active developments and
improvements. Ext4 file system is frequently used as 'root' file system for most Linux installations.
→ ReiserFS - alternative Linux file system designed to store huge amount of small files.
→ XFS - file system derived from SGI company that initially used it for their IRIX servers. Now XFS
specifications are implemented in Linux.
→ JFS - file system developed by IBM for their powerful computing systems. Currently this file
system is open-source and is implemented in most modern Linux distributions.

d) BSD, Solaris, Unix file systems


→ UFS (Unix File System) also often referred to FFS (Fast File System – fast compared to a previous
file system used for Unix).
→ ZFS for Solaris,

XI. DEVICE MANAGEMENT


Device management in an operating system refers to the process of managing various devices connected to
the computer. The device manager manages the hardware resources and provides an interface to the hardware
for application programs. A device communicates with the computer system by sending signals over a cable.
The device communicates with the machine through a connection point called port.
Broadly, managing input and output is a matter of managing queues and buffers. A buffer is a temporary
storage area that takes a stream of bits from a device like keyboard to a serial communication port. Buffers
hold the bits and then release them to the CPU at a convenient rate so that the CPU can act on it.
Spooling: SPOOL stands for simultaneous peripheral operation on-line. Spooling refers to storing
jobs in a buffer so that CPU can be efficiently utilized. Spooling is useful because devices access data at
different rates. The buffer provides a waiting station where data can rest while the slower device catches up.
The most common spooling application is print spooling. In print spooling, documents are loaded into a buffer,
and then the printer pulls them off from the buffer at its own rate.

XII. SECURITY MANAGEMENT


By NDANG George Page 19
Topic : OPERATING SYSTEM
Security in terms of a computer system covers every aspect of its protection in case of a catastrophic
event, corruption of data, loss of confidentiality and so on. Security requires ample protection not only within the
system, but also from the external environment, in which the system operates. Various security techniques
employed by the operating system to secure the information are user authentication and backup of data.

1) User Authentication
The process of authenticating users can be based on a user's possession like a key or card, user information
like the username and password or user attributes like fingerprints and signature. Among these techniques,
user information is often the first and most significant line of defence in a multiuser system. Unfortunately,
passwords can often be guessed, illegally transferred or exposed. To avoid such situations, a user should keep
the following points in mind:
1) Password should be at least six characters in length.
2) The system should keep track of any event about any attempt to break the password.
3) The system should allow limited number of attempts for submitting a password on a particular system.
4) Password based on dictionary words should be discouraged by the system. Alphanumeric passwords,
such as PASS011, should be used.

2) Backup of Data
To backup is to copy files to a second medium (a disk or tape) as a precaution in case the first medium fails.
One of the cardinal rules in using computers is back up your files regularly. OS provide a feature of backing up
of data, for example, from a disk to another storage device such as a floppy disk or an optical disk. The purpose
of keeping backups is to be able to restore individual files or complete file system in case of data loss.

3) Data encryption
Encryption is the conversion of data (called plaintext) into a form (called a cyphertext) that cannot
be easily understood by unauthorised user. Before being able to understand the content of the data, the receiver
must be in possession of an encryption key used to decrypt the cyphertext.

XIII. EXAMPLES OF OS
XIII.1 Commonly used OS
Some of the commonly used operating systems are discussed below:
1. DOS (Disk Operating System): MS- DOS was the widely used operating system before the introduction
of the Windows operating system. Even now the MS- DOS commands are used for carrying out many jobs like
copying the files, deleting the files etc. The main functions of DOS are to manage files, allocate system
resources according to the requirement. It provides essential features to control hardware devices such a
keyboard, screen, disk drives, printers, modems etc.

By NDANG George Page 20


Topic : OPERATING SYSTEM
2. Windows: Microsoft launched Windows 1.0 operating system in 1985 and since then Windows has ruled
the world’s software market. Various versions of Windows have been launched like Windows 95, 98, Win NT,
XP, 7 and the latest being Windows 8.
3. Linux: Linux is a free and open software which means it is freely available for use and its source code is
also available so anybody can use it, modify it and redistribute it. It is a very popular operating system used and
supported by many companies.
4. MAC OS (Macintosh operating system): It is the operating system developed by Apple for Mac
computers
5. BOSS (Bharat Operating System Solutions): This is an Indian distribution of GNU/Linux. It consists of
Linux operating system kernel, office application suite, Bharateeya OO, Internet browser (Firefox), multimedia
applications and file sharing.
6. UNIX: It is a multitasking, multiuser operating system originally developed in 1969 at Bell Labs. It was
one of the first operating systems developed in a high level language, namely C. Due to its portability,
flexibility and power, UNIX is widely being used in a networked environment.
7. Solaris: It is a free Unix based operating system introduced by Sun Microsystems in 1992. It is now also
known as Oracle Solaris.

XIII.2 Mobile Operating Systems (Mobile OS)


It is the operating system that operates on digital mobile devices like smart phones and tablets. It extends the
features of a normal operating system for personal computers so as to include touch screen, Bluetooth, Wi-Fi,
GPS mobile navigation, camera, music player and many more. The most commonly used mobile operating
systems are Android and Symbian
Android: It is a Linux derived Mobile OS released on 5th November 2007 and by 2011 it had more than
50% of the global Smartphone market share. It is Google’s open and free software that includes an operating
system, middleware and some key applications for use on mobile devices. Various versions of Android OS
have been released like 1.0, 1.5, 1.6, 2.x, 3.0 etc.
Symbian: This Mobile OS by Nokia designed for smartphones. It offers high level of functional
integration between communication and personal information management. It has an integrated mail box and it
completely facilitates the usage of all Google applications in your smartphone easily. Various versions like S60
series, S80 series, S90 series, Symbian Anna etc have been released.

By NDANG George Page 21


Topic : OPERATING SYSTEM

XIII.3 Comparison Linux & Windows


Linux WINDOWS
It is the family of operating system from
What is it?: it is an example of Open Source software
Microsoft, which is the most famous OS in
development and Free Operating System
the world.
Linux can be freely downloaded freely, For desktop or home use, Windows can be
Cost: distributed through magazines, Books etc. expensive. A single copy can cost around
There are priced versions for Linux also, but $50 to $ 450 depending on the version of
they are normally cheaper than Windows. Windows.
User: Everyone. From home users to developers and Everyone. From home users to developers
computer enthusiasts alike. and computer enthusiasts alike.
Microsoft created the Windows operating
Linux kernel is developed by the community.
Manufacturer: system, but allows other computer
Linus Torvalds oversees things.
manufactures to distribute their own
computers with Windows pre-installed.
Linux can be installed on a wide variety of
On PC's desktops, laptops, servers and some
Usage: computer hardware, ranging from mobile
phones.
phones, tablet computers and video game
consoles, to mainframes and supercomputers.
Development Linux is developed by Open Source development
and i.e. through sharing and collaboration of code and Windows is developed and distributed by
features through forums and it is distributed by Microsoft.
Distribution: various vendors.
The Windows GUI is an integral component
GUI: Linux typically provides two GUIs, KDE and
of the OS and it is mainly influenced by
Gnome. But Linux GUI is optional.
Mac OS and Xerox.
File system
Ext2, Ext3, Ext4, Jfs, ReiserFS, Xfs, Btrfs,
FAT, FAT32, NTFS, exFAT
support: FAT, FAT32, NTFS

Windows uses a command shell and each


BASH (Bourne Again SHell) is the Linux
Text mode version of Windows has a single command
default shell. It can support multiple command
interpreter with dos-like commands, recently
interface: interpreters.
there is the addition of the optional Power
Shell that uses more Unix-like commands.
Linux has had about 60-100 viruses listed till According to Dr. Nic Peeling and Dr Julian
Security: date. None of them actively spreading Satchell's, there have been more than 60,000
nowadays. viruses in Windows
threat detection and solution is very fast, as After detecting a major threat, Microsoft
Linux is mainly community driven and generally releases a patch that can fix the
Threat detection
whenever any Linux user posts any kind of problem and it can take more than 2/3
and solution:
threat, several developers start working on it months. Sometimes sooner, Microsoft
from different parts of the world releases patches and updates weekly.
Very few games available natively. Some Most games are compatible with Windows.
Gaming: games can be played through Wine, but often Some CPU intensive and graphics intensive
not all features are available. games are exclusive to Windows PC's.
Although there are many GUI applications,
most of the work is done through Terminal (a Everything can be controlled through GUI
User experience:
console window), and if a problem arrises GUI and incompatibility problems are rare.
is rarely usable to fix them.
Because hardware manufacturers, such as
Combined with newest DirectX versions
Graphics NVidia, often does not provide documentation
and full graphics card support the
performance: for linux developers, drivers can not use full
performance is almost as good as it can get.
card performance.

By NDANG George Page 22


Topic : OPERATING SYSTEM

By NDANG George Page 23

You might also like