ISO Unit 01 Fundamentals OS
ISO Unit 01 Fundamentals OS
IMPLEMENTATION OF
OPERATING SYSTEMS
DIDACTIC UNIT 1: FUNDAMENTALS OF OPERATING
SYSTEMS
INDEX
1. Definition of SO ......................................................................................................................................................................... 2
2. Historical development of SO .................................................................................................................................................... 2
2.1. Evolution of Windows OS ................................................................................................................................................ 4
2.2. Evolution of Apple's OS ................................................................................................................................................... 4
2.3. Evolution of Linux operating systems .............................................................................................................................. 5
3. Types of Operating Systems....................................................................................................................................................... 6
4. Current Operating Systems........................................................................................................................................................ 7
4.1. Mobile phones................................................................................................................................................................ 7
4.2. Personal Computers (PCs) ............................................................................................................................................... 7
5. Functions of an OS..................................................................................................................................................................... 9
A. PROCESS MANAGEMENT ........................................................................................................................................................ 10
1. Introduction ........................................................................................................................................................................ 10
2. Processes ............................................................................................................................................................................ 10
3. Process planning.................................................................................................................................................................. 12
4. Processes on Windows and Linux ......................................................................................................................................... 15
B. MEMORY MANAGEMENT ....................................................................................................................................................... 16
1. Introduction ........................................................................................................................................................................ 16
2. Relocation issue................................................................................................................................................................... 16
3. Memory protection problem ............................................................................................................................................... 17
4. Memory allocation problem ................................................................................................................................................ 17
5. Memory shortage problem. Virtual memory ........................................................................................................................ 17
6. Memory management on Linux and Windows ..................................................................................................................... 18
C. INPUT/OUTPUT MANAGEMENT .............................................................................................................................................. 18
1. Introduction ........................................................................................................................................................................ 18
2. Input/output unit ................................................................................................................................................................ 19
Input/output software............................................................................................................................................................. 19
4. Input/output hardware ........................................................................................................................................................ 19
5. Disk management ................................................................................................................................................................ 20
D. FILE MANAGEMENT ................................................................................................................................................................ 22
1. Introduction ........................................................................................................................................................................ 22
2. Files..................................................................................................................................................................................... 22
3. Directories........................................................................................................................................................................... 23
4. Allocation methods.............................................................................................................................................................. 24
5. Examples of file systems ...................................................................................................................................................... 25
1
1. DEFINITION OF SO
Operating System
Hardware
It was at the end of this decade that UNIX appeared, the basis of the
great majority of the Operating Systems that exist today.
2
In the 1990s Linux made its appearance,
releasing the first version of the kernel in
September 1991, which later joined the GNU project, a completely free
operating system, similar to UNIX, which lacked a functional kernel to
function. Today, most people know Linux as the operating system that is
actually called GNU/Linux.
3
2.1. EVOLUTION OF WINDOWS OS
4
2.3. EVOLUTION OF LINUX OPERATING SYSTEMS
5
ISO - Theme 1: Fundamentals of Operating Systems
3. TYPES OF OPERATING SYSTEMS
OS can be classified according to:
No. of users:
o Single user: only 1 user can use the system resources at a time
Therefore, even if more than one user is logged on to the system, if they cannot work simultaneously, the OS is not
multi-user.
No. of processors:
o Multiprocessing/multiprocessor: the OS is able to manage multiple processors, so that it can use them
simultaneously to distribute its workload. These systems work in two ways:
Asymmetric: the OS divides the tasks it is performing between the processors. Certain processes will
always be executed by one processor, and the other processor will only be used to carry out user
processes. In this case, it is possible that one process is always working and the other is sometimes
inactive.
Response time (time it takes for the user to obtain the results after starting the execution of a program):
o Batch processing: the response time is not important and is usually high. Processes are executed sequentially one
after the other. There is no user interaction. Example: backups
o Time sharing: the processor divides its time between all processes (using scheduling algorithms such as Roud Robin).
Example: interactive multi-user systems (users interact with the system).
o Real-time: in these OS, processes require a very low or immediate response time. Examples where this is especially
important: systems where response time is crucial such as medical systems for patient monitoring, banking systems,
air traffic...
Operating System No. of users No. of processes No. of processors Response time
MS-DOS Monkey Monkey Monkey Real
Windows 9x, Me Monkey Pseudo multitasking Monkey Shared
Windows NT Workstation, Mono/Multi Multi Multi Shared
2000 Professional,
XP/Vista/7/8
UNIX, Linux, Multi Multi Multi Shared
Windows NT Server, Windows
2000 Server, 2003 Server and
2008 Server
Note: Pseudo-multitasking OSs are OSs capable of loading more than one process into memory and seemingly running more
than one process at the same time. However, these OS are not capable of using more than 1 processor so that, in reality, only
one process is executed at a time (the processor executes sequentially each of the started processes).
6
ISO - Theme 1: Fundamentals of Operating Systems
Android
- Free OS created by Google and the OHA (Open Handset Alliance) which is a
consortium of hw and sw manufacturers and mobile operators.
- It can be installed on all types of mobile phone models and brands, as well as tablets,
netbooks...
iOS
- OS created by Apple
Windows
based versions).
- Closed code.
Microsoft's Windows OS is proprietary software, unlike Linux, which is free software, meaning that in order to install and use it on a
computer, a licence must be purchased.
Following Apple's Mac OS, Windows was one of the first to incorporate a window-based graphical user interface, hence its name.
In its early days, it was an application running on top of the text-mode interface OS MS-DOS, also developed by Microsoft, but later
became a real OS (with Windows 95).
Throughout its history, there have been several versions of Windows that have
added improvements in its graphical environment, in its performance, in the use
of the hardware characteristics of the computer and in the utilities
applications to facilitate the user's work.
Currently, the most widely used versions are Windows XP and Windows 7.
Linux
7
ISO - Theme 1: Fundamentals of Operating Systems
- Kernel type: Monolithic. Based on Unix OS. Latest stable kernel version : 3.6.1
It is a freely distributed OS, so it can be installed and updated free of charge. It is also open source, so we can use its source code to
introduce modifications or improvements.
Over the years, it has introduced significant improvements in graphical user interfaces. In addition, there are many distributions and
window managers for the graphical environment, so the user can choose the distribution that best suits his needs or the one he
likes the most, where he can choose which window manager he wants to use.
Linux has also improved considerably in terms of the hardware on which it is installed and in terms of improvements and new
features in the software that can be installed.
Mac OS X
OS X is an operating system developed and marketed by Apple that has been included in its range of Macintosh computers since
2002. It is based on BSD. Since Mac OS X 10.5 Leopard for Intel processors, the system is UNIX certified (this allows certification that
it can run certain software, such as Oracle).
Mac OS X version names are named after big cats, for example: Mac OS X v10.7 is called "Lion".
8
ISO - Theme 1: Fundamentals of Operating Systems
5. FUNCTIONS OF AN OS
With regard to the functions of any Operating System, we can highlight the following:
- Process management
- Memory management
- I/O device management
- File system management
- Network management
- Protection
C. I/O device management: the OS must be able to manage the different existing peripherals. To do so, the OS must:
Send commands to devices
Determining the device that needs the processor's attention
Detecting interruptions
Controlling errors
Provide an interface between the devices and the rest of the system, which should be simple and easy to use and the same
for all devices.
D. File system management: the OS must be able to provide a simple working model with disks. It must also be able to provide a
solution to the following problems:
Organisation of the file system (directories)
Allocation of disk space to information (in a non-contiguous way)
Management of free and occupied disk space
F. Protection: requires a mechanism to allow/deny a user process access to a resource (files, I/O devices). This requires:
Design of a protection model and policy to define which accesses are legal/illegal.
Implementation of a mechanism to monitor compliance with the defined protection rules.
Mechanism to guarantee the privacy of information against attacks by intruders.
9
ISO - Theme 1: Fundamentals of Operating Systems
A. PROCESS MANAGEMENT
1. Introduction
2. Processes
A process is an executing program that needs to be loaded into memory and have resources (CPU, memory, files, I/O devices) to
accomplish its purpose. It is an active entity. While programs are a set of files that are stored in some storage device (hard disk,
pendrive...) and whose source code is written in some programming language. When this set of files is executed, then it becomes a
process.
2.1 States
The state of a process is defined by its current activity, changing as it executes. The execution of a process alternates a series of CPU
and I/O bursts.
Process terminated
by another process
PREPARED IN
IMPLEMENTAT
Expulsion ION Wait for I/O
End I/O or or event
event arrival LOCKED
Process terminated
by another process
10
ISO - Theme 1: Fundamentals of Operating Systems
2.2 Implementation
When a process executes, the OS allocates it a memory address space (containing the instructions, data and stack (structure for
storing and retrieving data) of the process) and adds it to a process table.
The O.S. stores in the process table for each process a data structure called Process Control Block (PCB) that stores the following
information:
Process identification (of the process itself (PID), of the parent process (PPID) and of the user)
Process status information: ready, running, blocked...
Priority of the process
Memory address where the process was loaded
Other (resources used, values of processor registers, owner, permissions...)
To give a sense of concurrent execution or multi-scheduling, CPU time must be shared between processes. This involves context
switches that consist of taking CPU away from the "running" process and allocating it to another process in the "ready" state. This
operation is performed by an O.S. component called a dispatcher or short-term scheduler, which saves the context of the running
process on its PCB and restores the context of the new process to be executed via its PCB.
Inactive
In progress
In progress
Inactive
Contextual changes
Context switches can be overloading if they are used very frequently. In general, they usually occur when a process is terminated,
expelled or suspended.
2.3 Threads
In current O.S.'s a process can internally have several concurrent activities called threads.
They are like "mini-processes", small units into which a process is divided, each of which performs an action.
Processes running on a computer can be in the foreground or background. Foreground processes interact with users, while
background processes perform a specific function without user interaction. In addition, processes can be user-owned or OS-owned.
In this way, the operating system can create processes, some of which reside in the background and are called services in Windows
and daemons in Linux. The system administrator can start, stop, pause, resume... these services. The processes that belong to the
system run in kernel mode or privileged mode (they will be able to access any resource).
Other processes are user-created processes, where the user interacts with them, i.e. they run in the foreground, e.g. Firefox. These
processes run in so-called "user mode" (with restricted access to hardware resources).
11
ISO - Theme 1: Fundamentals of Operating Systems
3. Process planning
As mentioned above, in a multitasking O.S., multitasking is achieved through the alternative execution of processes.
The part of the O.S. responsible for selecting the next process to execute is the short-term scheduler and the algorithm it uses is the
scheduling algorithm.
o Selects processes not loaded in memory (new or ready processes that have been unloaded from memory) and
loads them into memory.
o Control the degree of multi-programming. It is important that you choose a balanced set of processes.
o It is executed infrequently.
Short-term planner:
o It selects from among the memory-ready processes and allocates the CPU to them.
Medium-term planner:
o It decides which process moves from main memory to secondary memory (virtual memory) or vice versa.
The O.S. links the PCBs of the processes that are in the same state to the various queues that may exist.
o Simple to implement.
12
ISO - Theme 1: Fundamentals of Operating Systems
They choose the next process to enter the CPU. The main scheduling algorithms are:
Advantages:
- Simple to implement (FIFO queue).
Disadvantages:
- Poor average waiting time.
- Convoy effect (processes with long CPU bursts slow down processes with short bursts).
- Not valid for interactive processes.
SJF (Shortest Job First) first which requires the least total CPU time
The process in the ready queue with the next shortest CPU streak is chosen and executed until it is terminated or suspended. If
there are multiple processes with equal CPU spans, FIFO can be applied. Non-expulsive algorithm.
Advantages:
- Optimise waiting time
Disadvantages:
- It is costly to find out how long the next CPU burst lasts
SRTF (Shortest Remainig Time First) first with the least CPU time left to finish.
Proprietary version of SJF (like SJF, only you can throw it into processes)
13
ISO - Theme 1: Fundamentals of Operating Systems
Prioritised planning first that which has the highest priority
Each process is assigned a priority. The scheduler selects the process with the highest priority (equal priority is selected with
FCFS).
Priorities can be dynamic (they change over time) or static (they remain the same).
Disadvantages:
- Risk of starvation of processes with low priority. One solution would be to increase the priority by increasing the
timeout.
- If the value of quantum is large the algorithm degenerates into FCFS. If it is small, an overhead will be generated due to
context switches.
- It is equitable
14
ISO - Theme 1: Fundamentals of Operating Systems
We can see the processes, as well as their CPU and RAM consumption:
- On Windows:
- On Linux:
15
ISO - Theme 1: Fundamentals of Operating Systems
B. MEMORY MANAGEMENT
1. Introduction
This will be followed by an analysis of the memory management problems that every OS must solve (memory reallocation,
protection, allocation and scarcity), as well as the
techniques used to solve them, with a special emphasis on
sparse allocation and virtual memory techniques.
Therefore, just as a computer has a physical memory, we can consider that each process has its logical or virtual memory.
2. Relocation issue
A process must be able to execute in different physical memory locations, which implies that references to memory that exist in the
program code have to be concretised in physical memory locations.
In addition, if a process is sent from main memory to secondary memory, when it is loaded back into main memory, it must be able
to do so in a different memory location than where it was initially.
This can be resolved at any of the following stages: In the following graph, we can see a comparison of
the methods:
- Compilation
- Charge
- Execution
16
ISO - Theme 1: Fundamentals of Operating Systems
Physical memory can be allocated to the various running processes using a variety of techniques:
- Contiguous allocation
- Dispersed allocation
The logical address space of a process is mapped onto a single area of physical memory: memory
addresses are contiguous.
Methods:
- Fixed partitions
- Variable partitions
Logical memory is divided into chunks (pages or segments), which are mapped onto non-
contiguous areas of physical memory.
To implement these techniques, the support of the MMU is needed. These techniques will not be studied in this course.
Techniques that provide a solution to this problem are: the swapping method (using the disk to store the memory image of
processes that do not fit) and the Virtual Memory technique.
The Virtual Memory technique allows processes to be executed without all their logical space being loaded in main memory by
using secondary memory (hard disk). It consists of loading into main memory the part of the process that is currently running, while
the part of the process that is not running is left in secondary memory.
- Memory saving
Disadvantages:
- Can reduce system performance if not
properly designed and synchronised
- Increased complexity
The basic virtual memory techniques: paging and demand segmentation. These techniques will not be studied in this course.
6. Memory management on Linux and Windows
- In page replacement it uses the clock algorithm - It uses a disk paging file called pagefile.sys, the size
(similar to LRU). of which is set in the control panel system
performance.
- It uses a swap partition called swap.
C. INPUT/OUTPUT MANAGEMENT
1. Introduction
Input/output management is one of the most important functions of the OS, as the OS must be able to handle the different
peripherals available.
To do so, it must:
18
ISO - Theme 1: Fundamentals of Operating Systems
- Scheduled I/O: The processor executes a program that controls I/O operations. The problem is that the processor has to
wait (continuously querying the I/O device) for a response.
- Interrupt-driven I/O: Devices send an interrupt signal to get the attention of the system. The processor can continue to
perform operations and attends to the I/O request when the interrupt occurs.
- I/O using DMA (direct memory access): a chip performs the transfer and accesses the memory to read or write data
received and sent by the device without passing through the processor.
Currently hard disks, CD, DVD, Blueray drives support DMA and have it enabled by default.
Since the speed of the processor is much higher than that of the I/O devices, buffering techniques are used to improve system
performance:
- Caching: consists of storing a temporary, fast-access cache of the most frequently used data. In this way, the most
frequently used data is not requested from the device (e.g. hard disk cache).
- Buffering: consists of using an area of memory as a buffer, simulating a device or a logical peripheral, which will act as an
intermediate device between the real peripheral and the processor. The buffer is independent of the input and/or output
device, so it allows the processor to start working by reading or buffering while the information from the peripheral is being
stored or extracted from the buffer. This prevents a slow peripheral from affecting the performance of the computer
equipment.
- Spooling: A technique in which the computer puts jobs into a buffer (a special area in memory or on a disk), so that a device
can access them when it is ready. Spooling is useful for devices that access data at different speeds. The buffer provides a
waiting place where data can sit until the (usually slower) device processes it. This allows the CPU to work on other tasks
while waiting for the slower device to finish processing the job.
The most common application of spooling is printing. In this case, documents are loaded onto an area of a disk, and the
printer spools them off the disk at its own speed and in a coordinated manner so that jobs are not mixed up. Spooling also
allows users to place several print jobs in a queue at once.
2. Input/output unit
4. Input/output hardware
19
ISO - Theme 1: Fundamentals of Operating Systems
Controllers:
The specific code that the OS uses to program a controller is known as the controller driver. Thus, in order to carry out I/O
tasks, the OS, using the driver, communicates with the controller through a series of specific registers that each controller has.
When the order has been fulfilled, the controller produces an interrupt in order to allow the CPU to attend the OS to check the
results of the I/O operation. The values of the controller registers that report the final state are used for this check.
I/O devices:
Peripherals can be classified according to whether they manage information by blocks or by characters.
5. Disk management
Disks are non-volatile mass storage. They support the file system and the virtual memory system.
You can have different types of file systems by partitioning a hard disk, i.e. dividing the physical disk into two logical disks.
- In order to have more than four partitions on a disk, there is a special type of partition, the extended partition. An extended
partition allows you to define an unlimited number of logical partitions within it.
- The MBR (Master Boot Record) occupies the first sector of the disk,
containing the boot program, the partition table with four entries and the
magic number (0xAA55). entries and the magic number (0xAA55).
- The remaining sectors of the disk may belong to a partition.
(formatted or not) or be available for assigning
- Each entry in the table contains the type of partition, if it is the partition
active or not and the start and end position on the disc
20
ISO - Theme 1: Fundamentals of Operating Systems
Structure of a disc:
Cylinder
Track
Head
The most costly is the seek time (time taken by the disk to move the
heads over the requested cylinder), so the requests to disk must be
planned in an order that minimises the head travel (following
algorithms such as FCFS, SSTF, SCAN...). This has to be achieved by
the device handler (driver).
Planning algorithms:
Closest cylinder first (shortest positioning time) Example: Spindle position: cylinder 53
Tail (no. of cylinders): 98, 183, 37, 122, 14, 124, 65, 67
Advantages: lower overall travel distances
21
ISO - Theme 1: Fundamentals of Operating Systems
SCAN (sweep)
Example: Spindle position: cylinder 53
The spindle travels from one end of the disc to the other, Tail (no. of cylinders): 98, 183, 37, 122, 14, 124, 65, 67
D. FILE MANAGEMENT
1. Introduction
- File or archive: Set of information of a certain type that is stored in a storage device. Example: text document, song, image...
- Folder or directory: A special type of file used to organise files (or other folders).
- File system: The part of the OS that allows the "management" of stored information from I/O devices in the form of files.
2. Files
o Name: Most OS allow names up to 255 characters long and some OS, such as Linux, are case-sensitive.
o Extension: it is used to know the program that allows to execute or open a file. Some OS like Linux do not require the
use of extensions.
- File types:
o Name
o Size
o Dates: of creation, modification...
o Owner
o Permissions (read, write, execute...)
o Location
o Links: points from which the file can be accessed.
o Create it
o Open it
o Write it down
o Close it
o Delete it
3. Directories
o Create it
o Entering it
o Getting out of it
o Read its contents
o Adding or deleting files or directories to or from it
o Delete it
- Directory structures:
Types:
o One level: all files in a single o Hierarchical: a directory can include other directories and files
directory
Most operating systems have a hierarchical file system structure, where directories start from one directory called the root
directory, from which all other directories hang in a tree-like structure, hence the use of terms such as subdirectory tree.
- Special directories:
o There are two types:
. → current directory
.. → parent directory
Types:
o Absolute: the file is called from the root directory to the file. Example:
C:\web\imagenes\logo.gif
o Relative: the file is called from the current directory we are in. Example:
if we are in the folder "web" the path to the file "logo.gif" would be:
imagenes/logo.gif
23
ISO - Theme 1: Fundamentals of Operating Systems
4. Allocation methods
1 5 8
d d d d d=data
end 5 from the
file
o Linked mapping: in each block there is part of the file data and a small part to
1st block of the file
indicate the next block containing the file data.
1 5 8
8
o Indexed allocation: for each file, the OS has a small index table indicating the
blocks of each file.
24
ISO - Theme 1: Fundamentals of Operating Systems
FAT16:
- The size of partitions and files could not exceed 2GB.
- The name of the files had to be 8 characters for the name and 3 characters for the extension.
FAT32:
- This file system was introduced for Windows 95 OS and was used by Win98 and Me.
- File names can have more characters (255) and files can be larger (4GB).
NTFS:
- It improves on the previous file system by introducing better security, greater stability and larger file sizes.
- It is used for Windows NT, 2000, XP, Vista, 7, 8 and Server 2000, 2003, 2008 and 2012.
- The ext3 version is an enhancement of ext2, with some new features such as journaling (a technique that records daily changes
to the file system so that data can be recovered in case of failure) and ext4 is an enhancement of ext3, with further
improvements such as support for larger partitions and files, improved reliability and speed.
OTHERS:
- Other file systems on Linux are XTS or reiserFS.
- In Mac OS we highlight the Mac OS Extended (HFS Plus) file system, which replaces HFS, and the UFS file system.
25