Module 5 Notes_2020
Module 5 Notes_2020
What Is OS ?
An Operating System (OS) is an interface between computer user and computer
hardware.
An operating system is 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.
Definition:
• An operating system is a program that acts as an interface between the user and the
computer hardware and controls the execution of all kinds of programs.
Following are some of important functions of an operating System.
• Memory Management
• Processor Management
• Device Management
• File Management
• Security
• Job accounting
An Operating System provides services to both the users and to the programs. It provides
programs an environment to execute.
• I/O operations
• Communication
• Error Detection
• Resource Allocation
• Protection
thousand to billions.
• Main memory stores the quickly accessible data shared by the CPU & I/O device.
• The central processor reads instruction from main memory during instruction
fetch cycle & it both reads &writes data from main memory during the data
fetch cycle.
• The main memory is generally the only large storage device that the CPU is able
to address & access directly.
• For example, for the CPU to process data from disk. Those data must first be
transferred to main memory by CPU generated E/O calls.
• Instruction must be in memory for the CPU to execute them. The OS is
responsible for the following activities in connection with memory
management.
▪ Keeping track of which parts of memory are currently being used & by
whom.
▪ Deciding which processes are to be loaded into memory when memory
space becomes available.
▪ Allocating &deal locating memory space as needed.
3. File Management:
• File management is one of the most important components of an OS
computer can store information on several different types of physical media
magnetic tape, magnetic disk & optical disk are the most common media.
• Each medium is controlled by a device such as disk drive or tape drive those
has unique characteristics.
• These characteristics include access speed, capacity, data transfer rate &
access method (sequential or random).For convenient use of computer
system the OS provides a uniform logical view of information storage.
• The OS abstracts from the physical properties of its storage devices to define
a logical storage unit the file.
Real time system is used when there are rigid time requirements on the operation of a
processor or flow of data. Sensors bring data to the computers. The computer analyzes
data and adjusts controls to modify the sensors inputs. System that controls scientific
experiments, medical imaging systems and some display systems are real time systems.
The disadvantages of real time system are: a. A real time system is considered to function
correctly only if it returns the correct result within the time constraints.
b. Secondary storage is limited or missing instead data is usually stored in short term
memory or ROM. c. Advanced OS features are absent. Real time system is of two types
such as
• Hard real time systems: It guarantees that the critical task has been completed on
time. The sudden task is takes place at a sudden instant of time.
• Soft real time systems: It is a less restrictive type of real time system where a
critical task gets priority over other tasks and retains that priority until it computes. These
have more limited utility than hard real time systems. Missing an occasional deadline is
acceptable e.g. QNX, VX works. Digital audio or multimedia is included in this category.
It is a special purpose OS in which there are rigid time requirements on the operation of a
processor. A real time OS has well defined fixed time constraints. Processing must be
done within the time constraint or the system will fail. A real time system is said to
function correctly only if it returns the correct result within the time constraint. These
systems are characterized by having time as a key parameter.
Task :
• Task is a piece of code or program that is separate from another task and can be
executed independently of the other tasks.
• In embedded systems, the operating system has to deal with a limited number of
tasks depending on the functionality to be implemented in the embedded system.
• Multiple tasks are not executed at the same time instead they are executed in
pseudo parallel i.e. the tasks execute in turns as the use the processor.
• From a multitasking point of view, executing multiple tasks is like a single book
being read by multiple people, at a time only one person can read it and then take
turns to read it.
• Different bookmarks may be used to help a reader identify where to resume
reading next time.
• An Operating System decides which task to execute in case there are multiple
tasks to be executed. The operating system maintains information about every task
and information about the state of each task.
• The information about a task is recorded in a data structure called the task context.
When a task is executing, it uses the processor and the registers available for all
sorts of processing. When a task leaves the processor for another task to execute
before it has finished its own, it should resume at a later time from where it
stopped and not from the first instruction. This requires the information about the
task with respect to the registers of the processor to be stored somewhere. This
information is recorded in the task context.
Task States
In an operation system there are always multiple tasks. At a time only one task can be
executed. This means that there are other tasks which are waiting their turn to be
executed.
Depending upon execution or not a task may be classified into the following three states:
• Running state - Only one task can actually be using the processor at a given time
that task is said to be the “running” task and its state is “running state”. No other
task can be in that same state at the same time
• Ready state - Tasks that are not currently using the processor but are ready to run
are in the “ready” state. There may be a queue of tasks in the ready state.
• Waiting state - Tasks that are neither in running nor ready state but that are
waiting for some event external to themselves to occur before the can go for
execution on are in the “waiting” state.
Process Concept:
Process scheduling:
Threads :
A process creates a thread through a system call. The thread does not have
resources of its own, so it does not have a context; it operates by using the
context of the process, and accesses the resources of the process through it.
We use the phrases ―thread(s) of a process‖ and ―parent process of a
thread‖ to describe the relationship between a thread and the process whose
context it uses.
Preemptive Scheduling:
It is the responsibility of CPU scheduler to allot a process to CPU whenever
the CPU is in the idle state. The CPU scheduler selects a process from ready
queue and allocates the process to CPU. The scheduling which takes place
when a process switches from running state to ready state or from waiting
state to ready state is called Preemptive Scheduling
P3 P1 P2 P4
0 2 5 9 14
P1 P2 P4 P1 P3
0 1 5 10 17 26
The waiting time for
process P1 = 10 - 1 =9
P2 = 1 – 1 = 0
P3 = 17 – 2 = 15
P4 = 5 – 3 = 2
The average waiting time = (9 + 0 + 15 + 2)/4 = 26/4 = 6.5
Round Robin Scheduling Algorithm: This type of algorithm is designed only for
the time sharing system. It is similar to FCFS scheduling with preemption
condition to switch between processes. A small unit of time called quantum time or
time slice is used to switch between the processes. The average waiting time under
the round robin policy is quiet long. Consider the following example:
Process CPU time
P1 3
P2 5
P3 2
P4 4
Time Slice = 1 millisecond.
P1 P2 P3 P4 P1 P2 P3 P4 P1 P2 P4 P2 P4 P2
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
The waiting time for process
P1 = 0 + (4 – 1) + (8 – 5) = 0 + 3 + 3 = 6
P2 = 1 + (5 – 2) + (9 – 6) + (11 – 10) + (12 – 11) + (13 – 12) = 1 + 3 + 3 + 1 +
1 + 1 = 10
P3 = 2 + (6 – 3) = 2 + 3 = 5
P4 = 3 + (7 – 4) + (10 – 8) + (12 – 11) = 3 + 3 + 2 + 1 = 9
The average waiting time = (6 + 10 + 5 + 9)/4 = 7.5
Task Communication :
A shared memory is an extra piece of memory that is attached to some address spaces for
their owners to use. As a result, all of these processes share the same memory segment
and have access to it. Consequently, race conditions may occur if memory accesses are
not handled properly. The following figure shows two processes and their address spaces.
The yellow rectangle is a shared memory attached to both address spaces and both
process 1 and process 2 can have access to this shared memory as if the shared memory is
part of its own address space. In some sense, the original address spaces is "extended" by
attaching this shared memory.
In computing, a named pipe (also known as a FIFO) is one of the methods for
interprocess communication.
It is an extension to the traditional pipe concept on Unix. A traditional pipe is
“unnamed” and lasts only as long as the process.
A named pipe, however, can last as long as the system is up, beyond the life of the
process. It can be deleted if no longer used.
Usually a named pipe appears as a file, and generally processes attach to it for
interprocess communication. A FIFO file is a special kind of file on the local storage
which allows two or more processes to communicate with each other by
reading/writing to/from this file.
A FIFO special file is entered into the filesystem by calling mkfifo() in C. Once we
have created a FIFO special file in this way, any process can open it for reading or
writing, in the same way as an ordinary file. However, it has to be open at both ends
simultaneously before you can proceed to do any input or output operations on it.
Message passing:
Message passing can be synchronous or asynchronous. Synchronous message passing
systems require the sender and receiver to wait for each other while transferring the
message. In asynchronous communication the sender and receiver do not wait for each
other and can carry on their own computations while transfer of messages is being done.
Message queue:
Mail box:
Mailboxes provide a means of passing messages between tasks for data exchange or task
synchronization. For example, assume that a data gathering task that produces data needs
to convey the data to a calculation task that consumes the data. This data gathering task
can convey the data by placing it in a mailbox and using the SEND command; the
calculation task uses RECEIVE to retrieve the data. If the calculation task consumes data
faster than the gatherer produces it, the tasks need to be synchronized so that only new
data is operated on by the calculation task. Using mailboxes achieves synchronization by
forcing the calculation task to wait for new data before it operates. The data producer puts
the data in a mailbox and SENDs it. The data consumer task calls RECEIVE to check
whether there is new data in the mailbox; if not, RECEIVE calls Pause() to allow other
tasks to execute while the consuming task is waiting for the new data.
Signaling :
signals are commonly used in POSIX systems. Signals are sent to the current process
telling it what it needs to do, such as, shutdown, or that it has committed an exception. A
process has several signal-handlers which execute code when a relevant signal is
encountered. The ANSI header for these tasks is <signal.h>, which includes routines to
allow signals to be raised and read.
Signals are essentially software interrupts. It is possible for a process to ignore most
signals, but some cannot be blocked. Some of the common signals are Segmentation
Violation (reading or writing memory that does not belong to this process), Illegal
Instruction (trying to execute something that is not a proper instruction to the CPU), Halt
(stop processing for the moment), Continue (used after a Halt), Terminate (clean up and
quit), and Kill (quit now without cleaning up).
RPC:
Process Synchronization
Consider a system consisting of n processes (P0, P1, ………Pn -1) each process
has a segment of code which is known as critical section in which the process
may be changing common variable, updating a table, writing a file and so on.
The important feature of the system is that when the process is executing in its
critical section no other process is to be allowed to execute in its critical
section.
The execution of critical sections by the processes is a mutually exclusive. The
critical section problem is to design a protocol that the process can use to
cooperate each process must request permission to enter its critical section. The
section of code implementing this request is the entry section. The critical
section is followed on exit section. The remaining code is the remainder
section.
Example:
While (1)
{
Entry Section;
Critical
Section; Exit
Section;
Remainder Section;
}
A solution to the critical section problem must satisfy the following three conditions.
waiting for the resource that is held by P2 ….. P(n – 1) is waiting for the
resource that is held by Pn and Pn is waiting for the resources that is held
by P4.
One aim of the IDE is to reduce the configuration necessary to piece together multiple
development utilities, instead providing the same set of capabilities as a cohesive unit.
Reducing that setup time can increase developer productivity, in cases where learning to
use the IDE is faster than manually integrating all of the individual tools. Tighter
integration of all development tasks has the potential to improve overall productivity
beyond just helping with setup tasks. For example, code can be continuously parsed
while it is being edited, providing instant feedback when syntax errors are introduced.
That can speed learning a new programming language and its associated libraries.
Some IDEs are dedicated to a specific programming language, allowing a feature set that
most closely matches the programming paradigms of the language. However, there are
many multiple-language IDEs, such as Eclipse, ActiveState Komodo, IntelliJ IDEA,
Oracle JDeveloper, NetBeans, Codenvy and Microsoft Visual Studio. Xcode, Xojo and
Delphi are dedicated to a closed language or set of programming languages.
While most modern IDEs are graphical, text-based IDEs such as Turbo Pascal were in
popular use before the widespread availability of windowing systems like Microsoft
Windows and the X Window System (X11). They commonly use function keys or
hotkeys to execute frequently used commands or macros.
A cross compiler is a compiler capable of creating executable code for a platform other
than the one on which the compiler is running. For example in order to compile for
Linux/ARM you first need to obtain its libraries to compile against.
A cross compiler is necessary to compile for multiple platforms from one machine. A
platform could be infeasible for a compiler to run on, such as for the microcontroller of
an embedded system because those systems contain no operating system. In
paravirtualization one machine runs many operating systems, and a cross compiler could
generate an executable for each of them from one main source.
Cross compilers are not to be confused with a source-to-source compilers. A cross
compiler is for cross-platform software development of binary code, while a source-
tosource "compiler" just translates from one programming language to another in text
code.
Both are programming tools.
What is a Disassembler?
Decompilers
Decompilers take the process a step further and actually try to reproduce the code in a
high level language. Frequently, this high level language is C, because C is simple and
primitive enough to facilitate the decompilation process. Decompilation does have its
drawbacks, because lots of data and readability constructs are lost during the original
compilation process, and they cannot be reproduced. Since the science of decompilation
is still young, and results are "good" but not "great", this page will limit itself to a listing
of decompilers, and a general (but brief) discussion of the possibilities of decompilation.
Tools
As with other software, embedded system designers use compilers, assemblers, and
debuggers to develop embedded system software. However, they may also use some
more specific tools:
For systems using digital signal processing, developers may use a math workbench such
as Scilab / Scicos, MATLAB / Simulink, EICASLAB, MathCad, Mathematica,or
FlowStone DSP to simulate the mathematics. They might also use libraries for both the
host and target which eliminates developing DSP routines as done in DSPnano RTOS.
model based development tool like VisSim lets you create and simulate graphical data
flow and UML State chart diagrams of components like digital filters, motor controllers,
communication protocol decoding and multi-rate tasks. Interrupt handlers can also be
created graphically. After simulation, you can automatically generate C-code to the
VisSim RTOS which handles the main control task and preemption of background tasks,
as well as automatic setup and programming of on-chip peripherals.
Debugging
An in-circuit debugger (ICD), a hardware device that connects to the microprocessor via
a JTAG or Nexus interface. This allows the operation of the microprocessor to be
controlled externally, but is typically restricted to specific debugging capabilities in the
processor.
An in-circuit emulator (ICE) replaces the microprocessor with a simulated equivalent,
providing full control over all aspects of the microprocessor.
A complete emulator provides a simulation of all aspects of the hardware, allowing all of
it to be controlled and modified, and allowing debugging on a normal PC. The
downsides are expense and slow operation, in some cases up to 100X slower than the
final system. For SoC designs, the typical approach is to verify and debug the design on
an FPGA prototype board. Tools such as Certus are used to insert probes in the FPGA
RTL that make signals available for observation. This is used to debug hardware,
firmware and software interactions across multiple FPGA with capabilities similar to a
logic analyzer.
Unless restricted to external debugging, the programmer can typically load and run
software through the tools, view the code running in the processor, and start or stop its
operation. The view of the code may be as HLL source-code, assembly code or mixture
of both.
Simulation is the imitation of the operation of a real-world process or system over time.[1]
The act of simulating something first requires that a model be developed; this model
represents the key characteristics or behaviors/functions of the selected physical or
abstract system or process. The model represents the system itself, whereas the
simulation represents the operation of the system over time.
Key issues in simulation include acquisition of valid source information about the
relevant selection of key characteristics and behaviours, the use of simplifying
approximations and assumptions within the simulation, and fidelity and validity of the
simulation outcomes.
Emulator
This article is about emulators in computing. For a line of digital musical instruments,
see
E-mu Emulator. For the Transformers character, see Circuit Breaker
(Transformers).#Shattered Glass. For other uses, see Emulation (disambiguation).
The above described focus on exact reproduction of behavior is in contrast to some other
forms of computer simulation, in which an abstract model of a system is being
simulated.
For example, a computer simulation of a hurricane or a chemical reaction is not
emulation.
still if the embedded system does not function the way it was supposed to be then it can
be either because of a hardware problem or a software problem. Assuming that the
hardware is perfect all that remains to check is the software.
• The difficult part here is that once the embedded system starts functioning there is
no way for the user or programmer to know the internal state of the components on
the target board.
• The most primitive method of debugging is using LEDs. This is similar to using a
printf or a cout statement in c/c++ programs to test if the control enters the loop or
not. Similarly an LED blind or a pattern of LED blinks can be used to check if the
control enters a particular piece of code.
Remote Debuggers
• Remote Debugger is a tool that can be commonly used for:
• Downloading
• Executing and
• Debugging embedded software
• A Remote Debugger contains a hardware interface between the host computer and
the target embedded system.