Computer block diagram
The components of the computer hardware can be called / seen as resources also.
System programs or System software can directly interact with the computer hardware.
Application programs are more user focused. They are used by the end user of the computer.
Ex include compilers, ides, text editors and word processors
So the OS is the master program of the entire computer hardware and controls all of the
hardware. It tells the hardware what to do based on the needs of the application we are using.
The apps requests are handled by the os, like to save a file, all things like How to save where to
save and how much memory should be saved all these kinds of things are handled by the OS.
Functions, goals and types of OS.
Some basics needed from CoA for OS:
The CPU here refers to the processor
The disks keyboards, etc are all connected to corresponding controllers. They make the data
acccessible to the bus.
All these controllers along with the CPU will work concurrently, at the same time. This helps in
understanding why computer wont pause videoplayback while replying to a message and how it
is simultaneously allow a zoom meeting going on.
For a seamless concurrency, te memory controller helps in orderly access to the memory.
The line represents the common bus in the computer
Some important terms
Kernel is the heart of the OS. It is the main part of the OS
The interrupts are used by software or hardware to signal occurrences of events. This makes
the CPU stop whatever it is doing, and starts executing the interrupt related items.
When hardware makes an interrupt it is called as interrupt directly. Incase it is done by software,
then it is called as a System call.
System calls are done by user programs in case there is a need to perform a privileged
operation.
Response of a CPU to an interrupt
Whenever there is an interrupt, the CPU pauses the current execution, and executes the service
routine, by going to the starting address of the service routine.
A service routine is like a procedure that has to be followed in case there is an interrupt,
and interrupts are raised, just to execute the InterruptServiceRoutines, (ISRs)
Storage structures
Computer-System Organization
We have already studied computer-system operation which dealt with the system's structure and
we also saw how interrupts are handled by the processor. After the computer-system operation
comes the storage structure. Storage is an integral part of a computer system because all the data
need to be stored somewhere. We have different types of storage devices which are used
according to the specific requirements of the system.
Storage Structure
The CPU (processor) fetches the instructions of the program to be executed from the memory.
So, in order to run any program or to execute any file, it must be stored in the memory first. In
general-purpose computers, these programs need to be brought into the main memory to get
executed.
Main Memory
All the currently running programs are kept in the main memory. These programs do not reside
permanently in it since the main memory is limited in size. Instead, for storing the programs or
files we use secondary memory from where the needed files are fetched into the main memory
whenever the need arises. For instance, when we install a software, it gets stored in the
secondary memory but when it needs to be executed (i.e., when we open it), all the files related
to that software get loaded into the main memory.
There are some points that we must know about main memory. They are as follows:
· It is often referred to as RAM or Random-Access Memory. As the name suggests, the
memory is accessed randomly (in any order) in this case as opposed to sequential access
where any memory location can be accessed only by following a proper sequence.
Let's take a basic example to get an idea of RAM.
Suppose, we have a class of 5 students who are sitting on separate benches, each one behind
another. The teacher wants the 3rd child to come to him. Now, there are two ways he can make
that happen. Either he can go to the first student and ask him to pass the message along to the
2nd child to tell the 3rd child that he needs to go to the teacher or he (teacher) can directly call
out his name and ask him to come to him. In the former case, the message travels through every
student before finally reaching the 3rd one. If the number of children sitting in between are more,
then consequently more time would be consumed to convey the message. This does not happen
in the second case, rather the message (i.e., teacher is calling) gets directly delivered to the
intended child (i.e., the 3rd child). Similarly, in the memory, when we are accessing a memory
cell randomly, we can get to the desired location directly without going through the other cells.
Hence, time is not wasted in interacting with other memory locations.
The main memory works in similar manner.
· It is implemented using a semiconductor technology called DRAM which stands for
Dynamic Random-Access Memory.
· It is volatile in nature which means that it loses its contents as soon as the power is
switched off.
· It is very fast to access but due to its size limitation we use secondary storage devices to
store data.
For main memory, there are different kinds of RAMs some of which are non-volatile too e.g.,
NVRAM. It has a battery backup power and remains non-volatile as long as the battery lasts.
Secondary Memory
Most computer systems provide secondary storage as an extension to the main memory since
main memory is limited. It is not possible to store all the data in it. In comparison to that
secondary storage can be of very large capacity, moreover, plus it holds the data permanently.
Storage devices with the storage sizes in terabytes are also available in the market these days.
Some commonly used storage devices are magnetic disks, flash drives, memory cards etc. Also,
all these devices are non-volatile.
Non-volatility is the exact opposite of volatility. It refers to the feature that the data will still be
present in the device even after the power supply of the device is cut off.
The given diagram shows a hierarchical structure of storage devices:
STORAGE-DEVICE HIERARCHY
We have the following devices shown here:
Registers: They are the smallest memory devices which we use to store data in bits.
Cache: It is an extremely fast temporary storage which is used to keep frequently used data.
Main Memory: We have already discussed about the main memory. It is the memory that the
computer uses most of the times.
Electronic disks: Electronic disks are (e.g., Solid State Devices (SSDs)) which are faster than
magnetic disks and are non-volatile.
Magnetic disk: Magnetic disk is the most commonly used secondary-storage device which
provides storage for data as well as programs.
Solid State Devices: These devices are semiconductor-based. Electricity in them flows through
the semi-conductor crystals.
Optical disks: This type of storage uses optical technology to store and access data. CDs, DVDs
and Blu-ray disks are some of its examples.
Magnetic tapes: Devices like cassettes have this long magnetically-coated film mounted on them.
It is a type of sequential memory.
Now let's compare these all with the help of the diagram given above.
On the top most level we have registers which, as we mentioned earlier, are the smallest storage
devices in the hierarchy and are extremely fast to access. Next comes the cache which is
relatively bigger than registers in capacity but is a little slower in comparison to them. It contains
the data which the CPU uses time and again. Although, cache memory in itself is a very fast
memory.
After cache, we have the main memory which is then followed by the secondary storage devices.
The pyramid-like structure follows a specific arrangement in terms of various measuring factors
like cost per bit (money required for each bit), size, access time, etc.
We notice that as the structure progresses down, the size of the devices to hold or store data also
increases but the cost per bit decreases. The upper most level of the hierarchy (i.e., registers) is
the fastest among all and as we move down, the access time of the data increases.
In the above diagram, devices in the upper part of the hierarchy are labelled as volatile, that is,
registers, cache memory and the main memory are volatile whereas the lower part of the pyramid
which contains the secondary storage devices is labelled as non-volatile.
Electronic disks can sometimes be made volatile.
Conclusion
We conclude on the note that there are variety of storage devices that we use in modern
computer systems. The usage of all these depends upon the requirements and of course certain
tasks require a certain type of storage or memory, for example, for loading and executing the
files the system uses the main memory only. The storage-device hierarchy is the arrangement of
these devices in such a manner that factors like access time, capacity and cost per bit can be
highlighted in a pattern so that we can compare their features.
There is NV ram that has battery backup to retain its data incase of power loss.
i/o structure
Most of OS code will be for managing I/O because reliability and performance of OS depends
on it.
Simply the device driver makes the device familiar to the OS. This makes it easy for the OS to
interact with the device according to the needs of the user
Working of an I/O operation
✅ “Loading registers” = The driver writes values into those registers
Imagine a program wants to read data from a disk.
1. Program calls read() → triggers a system call
2. OS calls the disk driver
3. Driver writes to controller registers:
· Operation type: READ
· Memory buffer address
· Number of bytes
1. The controller hardware takes over and talks to the disk
2. When done, it raises an interrupt to say “I’m finished!”
“When the OS needs a device to perform an operation, it asks the device driver. Based on the
system call the OS received, the driver writes specific values into the device controller’s
registers. These values tell the controller what operation to do and how to do it.”
Quick Recap Mnemonic:
Remember this flow as:
User → OS → Driver → Controller → Device
(You can use the phrase “UODCD” — like a delivery chain where commands are passed step-
by-step.)
Computer-System Organization
Under computer-system organization, we previously studied Computer-System Operation and
Storage Structure. Now, we are going to go through the final topic that comes under this section,
that is, the I/O structure. All these 3 components put together make up the concept of the basics
of the operating system.
I/O structure
There are a lot of I/O devices associated with a computer system among which storage is also
one. By I/O devices, we mean those devices which are used either to take input from the user or
to give out the output. Some examples of I/O devices are keyboard, mouse, monitor, scanner, etc.
The process of managing input-output is of extreme importance to the smooth and efficient
working of a computer. Without a proper I/O management system, it will be very difficult to
examine and fulfill the needs of the user since input determines what data the user wants to feed
to the system and output is how he wants it to be given out e.g., on paper or on the screen.
A significant part of the operating system deals with handling I/O operations as it largely affects
the reliability and performance of a computer. We mentioned earlier, there are various kinds of
I/O devices that the computer works with. So, basically different devices require different
instructions.
We studied in computer-system operation that each device needs a specific device controller to
interact with the memory. Conversely, a device controller may control several devices attached
to it. Along with its various other functionalities, there is another one for which it keeps a record
of local buffer storage and also maintains a set of special purpose registers for a device.
Now, these device controllers cannot handle the interaction between the devices and the
operating system alone. So, to provide the operating system with a uniform interface to the
device, we have a device driver for each device controller.
Device driver: It acts as a translator between the hardware devices and operating system. A
device driver is a software program which is used to operate the devices whereas a device
controller is a hardware unit attached to the I/O bus.
Device driver is more of an interface while a device controller is like a physical intermediary.
Working of an I/O operation
With the help of the following diagram, we are going to try to understand how does an I/O
operation take place:
HOW A MODERN COMPUTER SYSTEM WORKS
The following steps are taken:
1. The first and the foremost thing that has to be done in order to initiate an I/O operation is
the loading of the suitable registers to work upon. It is the responsibility of the device
driver to choose the required registers from the available set in the device controller and
load them.
2. The device controller then checks what is inside these registers to determine what it needs
to do next. These registers contain the exact information about the I/O operation.
3. Now, the data from the device needs to be transferred to the local buffer storage of the
controller. After finishing this transfer, the device controller must send a signal to the
device driver conveying the message that it has completed the operation. It does this task
through an interrupt.
4. Finally, the control is returned to the operating system. For a read operation, the last task
is to return the data (or a pointer to the data). For the rest of the operations, the status
information of the process is returned.
Generally, the above sequence of steps is carried out whenever we have to deal with a small
quantity of data. But this interrupt-driven operation for I/O tasks can create problems such as
high overhead for bulky data because transfer between a fast storage device such as a magnetic
disk is limited by the interference of the CPU. To overcome this problem, we use the concept of
DMA which expands as Direct Memory Access.
Direct Memory Access
Removing the CPU from the path and letting the peripheral device interact with the memory
directly without CPU's intervention is the whole idea of DMA.
After the initial loading of registers, buffers, pointers and counters for the specific I/O device, the
back-and-forth transfer of the entire data happens between the buffer storage and the memory
without bringing in the CPU. This improves the speed of the transfer.
Unlike the interrupt-driven I/O operation, in which the CPU had to be interrupted again and
again (interrupt was generated per byte), the DMA system needs only one interrupt per block at
the time of completion of the task.
Meanwhile, since the CPU is not involved, it is free to do other tasks instead of sitting idle.
Conclusion
I/O structure is just as much important as Computer-System Operation and Storage Structure.
We saw how the device driver comes into play along with the device controller for each device.
We have discussed the working of the I/O operation and now, we know that other than the
interrupt-driven operation we also use the DMA technique to transfer data between memory and
the devices. For smooth and efficient working of the computer system, the proper functioning of
the I/O structure is necessary.
One interrupt per block is generated usinf DMA. In the other case, one interrupt per byte was
the case. The cpu does remaining works in the meantime