Os Case Study
Os Case Study
EVOLUTION OF UNIX
WHAT IS LINUX?
Just like Windows XP, Windows 7, and Mac OS X, Linux is an operating system. An
operating system manages all of the hardware resources associated with your desktop or
laptop. The kernel is the core of the system and manages the CPU, memory, and peripheral
devices.
LINUX PROCESSES
For the Linux to manage the processes in the system, each process is represented by a
task_struct data structure. The task vector is an array of pointers to every task_struct data
structure in the system. As processes are created, a new task_struct is allocated from
system memory and added into the task vector.
Although the task_struct data structure is quite large and complex, but its fields can be
divided into a number of functional areas:
State
Running
The process is either running (it is the current process in the system) or it is ready to
run (it is waiting to be assigned to one of the system's CPUs).
Waiting
The process is waiting for an event or for a resource. Linux differentiates between
two types of waiting process; INTERRUPTIBLE and UNINTERRUPTIBLE.
Interruptible waiting processes can be interrupted by signals whereas uninterruptible
waiting processes are waiting directly on hardware conditions and cannot be
interrupted under any circumstances.
Stopped
The process has been stopped, usually by receiving a signal. A process that is being
debugged can be in a stopped state.
Zombie
This is a halted process which, for some reason, still has a task_struct data structure
in the task vector. It is what it sounds like, a dead process.
Scheduling Information
The scheduler needs this information in order to fairly decide which process in the
system most deserves to run,
Identifiers
Every process in the system has a process identifier. The process identifier is not an
index into the task vector, it is simply a number. Each process also has User and
group identifiers, these are used to control this processes access to the files and
devices in the system,
Inter-Process Communication
Linux supports the classic Unix TM IPC mechanisms of signals, pipes and
semaphores and also the System V IPC mechanisms of shared memory,
semaphores and message queues. The IPC mechanisms supported by Linux are
described in Chapter IPC-chapter.
The kernel keeps track of a processes creation time as well as the CPU time that it
consumes during its lifetime. Each clock tick, the kernel updates the amount of time
in jiffies that the current process has spent in system and in user mode. Linux also
supports process specific INTERVAL timers, processes can use system calls to set
up timers to send signals to themselves when the timers expire. These timers can be
single-shot or periodic timers.
Virtual memory
Most processes have some virtual memory (kernel threads and daemons do not) and
the Linux kernel must track how that virtual memory is mapped onto the system's
physical memory.
A process could be thought of as the sum total of the system's current state.
Whenever a process is running it is using the processor's registers, stacks and so on.
This is the processes context and, when a process is suspended, all of that CPU
specific context must be saved in the task_struct for the process. When a process is
restarted by the scheduler its context is restored from here.
PROCESS SYSTEM CALLS
Processes are the most fundamental abstraction in a Linux system, after files. As object code in
execution - active, alive, running programs - processes are more than just assembly language; they
consist of data, resources, state, and a virtualized computer. • Linux took an interesting path, one
seldom traveled, and separated the act of reating a new process from the act of loading a new binary
image. Although the two tasks are performed in tandem most of the time, the division has allowed a
great deal of freedom for experimentation and evolution for each of the tasks. This road less traveled
has survived to this day, and while most operating systems offer a single system call to start up a new
program, Linux requires two: a fork and an exec.
Pocess id
Session id
Process group id
First Come First Serve is the full form of FCFS. It is the easiest and most simple CPU
scheduling algorithm. In this type of algorithm, the process which requests the CPU gets the
CPU allocation first. This scheduling method can be managed with a FIFO queue.
As the process enters the ready queue, its PCB (Process Control Block) is linked with the tail
of the queue. So, when CPU becomes free, it should be assigned to the process at the
beginning of the queue.
It offers non-preemptive and pre-emptive scheduling algorithm.
Jobs are always executed on a first-come, first-serve basis
It is easy to implement and use.
However, this method is poor in performance, and the general wait time is quite high.
The full form of SRT is Shortest remaining time. It is also known as SJF preemptive
scheduling. In this method, the process will be allocated to the task, which is closest to its
completion. This method prevents a newer ready state process from holding the completion of
an older process.
This method is mostly applied in batch environments where short jobs are required to be
given preference.
This is not an ideal method to implement it in a shared system where the required CPU time
is unknown.
Associate with each process as the length of its next CPU burst. So that operating system
uses these lengths, which helps to schedule the process with the shortest possible time.
Priority scheduling is a method of scheduling processes based on priority. In this method, the
scheduler selects the tasks to work as per the priority.
Priority scheduling also helps OS to involve priority assignments. The processes with higher
priority should be carried out first, whereas jobs with equal priorities are carried out on a
round-robin or FCFS basis. Priority can be decided based on memory requirements, time
requirements, etc.
Round-Robin Scheduling
Round robin is the oldest, simplest scheduling algorithm. The name of this algorithm comes
from the round-robin principle, where each person gets an equal share of something in turn. It
is mostly used for scheduling algorithms in multitasking. This algorithm method helps for
starvation free execution of processes.
Round robin is a hybrid model which is clock-driven
Time slice should be minimum, which is assigned for a specific task to be processed.
However, it may vary for different processes.
It is a real time system which responds to the event within a specific time limit.
SJF is a full form of (Shortest job first) is a scheduling algorithm in which the process with the
shortest execution time should be selected for execution next. This scheduling method can be
preemptive or non-preemptive. It significantly reduces the average waiting time for other
processes awaiting execution.
It is associated with each job as a unit of time to complete.
In this method, when the CPU is available, the next process or job with the shortest
completion time will be executed first.
It is Implemented with non-preemptive policy.
This algorithm method is useful for batch-type processing, where waiting for jobs to complete
is not critical.
It improves job output by offering shorter jobs, which should be executed first, which mostly
have a shorter turnaround time.
This algorithm separates the ready queue into various separate queues. In this method,
processes are assigned to a queue based on a specific property of the process, like the
process priority, size of the memory, etc.
However, this is not an independent scheduling OS algorithm as it needs to use other types of
algorithms in order to schedule the jobs.
Multiple queues should be maintained for processes with some characteristics.
Every queue may have its separate scheduling algorithms.
Priorities are given for each queue.