MODULE 2 - PART2 Computer System Architecture
MODULE 2 - PART2 Computer System Architecture
MODULE 2 - PART2 Computer System Architecture
We use memory to store the information, which includes both program and data.
Due to several reasons, we have different kind of memories. We use different kind of memory at
different lavel.
Internal and
external
Internal memory is used by CPU to perform task and external memory is used to store bulk
information, which includes large software and data.
Memory is used to store the information in digital form. The memory hierarchy is given by:
Register
Cache Memory
Main Memory
Magnetic Disk
Removable media (Magnetic tape)
Register:
This is a part of Central Processor Unit, so they reside inside the CPU. The information from
main memory is brought to CPU and keep the information in register. Due to space and cost
constraints, we have got a limited number of registers in a CPU. These are basically faster
devices.
Cache Memory:
Cache memory is a storage device placed in between CPU and main memory. These are
semiconductor memories. These are basically fast memory device, faster than main
memory.
We can not have a big volume of cache memory due to its higher cost and some constraints
of the CPU. Due to higher cost we can not replace the whole main memory by faster
memory. Generally, the most recently used information is kept in the cache memory. It is
brought from the main memory and placed in the cache memory. Now a days, we get CPU
with internal cache.
Main Memory:
Like cache memory, main memory is also semiconductor memory. But the main memory is
relatively slower memory. We have to first bring the information (whether it is data or
program), to main memory. CPU can work with the information available in main memory
only.
Magnetic Disk:
This is bulk storage device. We have to deal with huge amount of data in many application.
But we don't have so much semiconductor memory to keep these information in our
computer. On the other hand, semiconductor memories are volatile in nature. It loses its
content once we switch off the computer. For permanent storage, we use magnetic disk. The
storage capacity of magnetic disk is very high.
Removable media:
For different application, we use different data. It may not be possible to keep all the
information in magnetic disk. So, which ever data we are not using currently, can be kept in
removable media. Magnetic tape is one kind of removable medium. CD is also a removable
media, which is an optical device.
Register, cache memory and main memory are internal memory. Magnetic Disk, removable media
are external memory. Internal memories are semiconductor memory. Semiconductor memories are
categoried as volatile memory and non-volatile memory.
RAM: Random Access Memories are volatile in nature. As soon as the computer is switched off,
the contents of memory are also lost.
ROM: Read only memories are non volatile in nature. The storage is permanent, but it is read only
memory. We can not store new information in ROM.
PROM: Programmable Read Only Memory; it can be programmed once as per user
requirements.
EPROM: Erasable Programmable Read Only Memory; the contents of the memory can be
erased and store new data into the memory. In this case, we have to erase whole
information.
EEPROM: Electrically Erasable Programmable Read Only Memory; in this type of memory
the contents of a particular location can be changed without effecting the contents of other
location.
Main Memory
The main memory of a computer is semiconductor memory. The main memory unit
of computer is basically consists of two kinds of memory:
RAM : Random access memory; which is volatile in nature.
ROM : Read only memory; which is non-volatile.
The permanent information are kept in ROM and the user space is basically in RAM.
The smallest unit of information is known as bit (binary digit), and in one memory cell
we can store one bit of information. 8 bit together is termed as a byte.
The maximum size of main memory that can be used in any computer is determined
by the addressing scheme.
A computer that generates 16-bit address is capable of addressing upto 216 which is
equal to 64K memory location. Similarly, for 32 bit addresses, the total capacity will
be 232 which is equal to 4G memory location.
In some computer, the smallest addressable unit of information is a memory word
and the machine is called word-addressable.
Due to that, the main memory of a computer is divided into two parts. One part is
reserved for operating system. The other part is for user program. The program
currently being executed by the CPU is loaded into the user part of the memory. The
two parts of the main memory are shown in the figure 3.17.
In a uni-programming system, the program currently being executed is loaded into
the user part of the memory.
In a multiprogramming system, the user part of memory is subdivided to accomodate
multiple process. The task of subdivision is carried out dynamically by opearting
system and is known as memory management.
Efficient memory management is vital in a multiprogramming system. If only a few process are in
memory, then for much of the time all of the process will be waiting for I/O and the processor will
idle. Thus memory needs to be allocated efficiently to pack as many processes into main memory as
possible.
When memory holds multiple processes, then the process can move from one process to another
process when one process is waiting. But the processor is so much faster then I/O that it will be
common for all the processes in memory to be waiting for I/O. Thus, even with multiprogramming, a
processor could be idle most of the time.
Due to the speed mismatch of the processor and I/O device, the status at any point
in time is reffered to as a state.
There are five defined state of a process as shown in the figure 3.18.
When a process starts to execute, it is placed in the process queue and it is in the
Due to the speed mismatch of the processor and I/O device, the status at any point
in time is reffered to as a state.
There are five defined state of a process as shown in the figure 3.18.
When a process starts to execute, it is placed in the process queue and it is in the
new state. As resources become available, then the process is placed in the ready
queue.At any given time a process may be in one of the following five states.
1.New : A program is admitted to execute, but not yet ready to execute. The operating
system will initialize the process by moving it to the ready state.
2.Ready : The process is ready to execute and is waiting access to the processor.
3.Running: The process is being executed by the processor. At any given time, only one
process is in running state.
4.Waiting : The process is suspended from execution, waiting for some system resource, such
as I/O.
5.Exit : The process has terminated and will be destroyed by the operating system.
The processor alternates between executing operating system instructions and executing user
processes. While the operating system is in control, it decides which process in the queue sholud be
executed next.
A process being executed may be suspended for a variety of reasons. If it is suspended because the
process requests I/O, then it is places it in the appropriate I/O queue. If it is suspended because of a
timeout or because the operating system must attend to other urgent processing task, then it is
placed in ready state.
We know that the information of all the process that are in execution must be placed in main
memory. Since there is fix amount of memory, so memory management is an important issue.
In an uniprogramming system, main memory is divided into two parts : one part for the operating
system and the other part for the program currently being executed.
In multiprogramming system, the user part of memory is subdivided to accomodate multiple
processes.
The task of subdivision is carried out dynamically by the operating system and is
known as memory management.
In uniprogramming system, only one program is in execution. After complition of one
program, another program may start.
In general, most of the programs involve I/O operation. It must take input from some
input device and place the result in some output device.
Partition of main memory for uni-program and multi program is shown in figure 3.19.
To utilize the idle time of CPU, we are shifting the paradigm from uniprogram environment to
multiprogram environment.
Since the size of main memory is fixed, it is possible to accomodate only few process in the main
memory. If all are waiting for I/O operation, then again CPU remains idle.
To utilize the idle time of CPU, some of the process must be off loaded from the memory and new
process must be brought to this memory place. This is known swapping.
What is swapping :
1. The process waiting for some I/O to complete, must stored back in disk.
2. New ready process is swapped in to main memory as space becomes
available.
3. As process completes, it is moved out of main memory..
But swapping is an I/O process, so it also takes time. Instead of remain in idle state of CPU,
sometimes it is advantageous to swapped in a ready process and start executing it.
The main question arises where to put a new process in the main memory. It must be done in such a
way that the memory is utilized properly.
Partitioning
Splitting of memory into sections to allocate processes including operating system. There are two
scheme for partitioning :
The mamory is partitioned to fixed size partition. Although the partitions are of fixed size, they need
not be of equal size.
There is a problem of wastage of memory in fixed size even with unequal size. When a process is
brought into memory, it is placed in the smallest available partition that will hold it.
Equal size and unequal size partition ofr fixed size partitions of main memory is shown in Figure
3.20.
Even with the use of unequal size of partitions, there will be wastage of memory. In most cases, a
process will not require exactly as much memory as provided by the partition.
For example, a process that require 5-MB of memory would be placed in the 6-MB partition which
is the smallest available partition. In this partition, only 5-MB is used, the remaining 1-MB can not
be used by any other process, so it is a wastage. Like this, in every partition we may have some
unused memory. The unused portion of memory in each partition is termed as hole.
When a processe is brought into memory, it is allocated exactly as much memory as it requires and
no more. In this process it leads to a hole at the end of the memory, which is too small to use. It
seems that there will be only one hole at the end, so the waste is less.
But, this is not the only hole that will be present in variable size partition. When all processes are
blocked then swap out a process and bring in another process. The new swapped in process may
be smaller than the swapped out process. Most likely we will not get two process of same size. So,
it will create another whole. If the swap- out and swap-in is occuring more time, then more and more
hole will be created, which will lead to more wastage of memory.
There are two simple ways to slightly remove the problem of memory wastage:
Coalesce : Join the adjacent holes into one large hole , so that some process can be
accomodated into the hole.
Compaction : From time to time go through memory and move all hole into one free block of
memory.
Example
Consider a main memory of 2-MB out of which 512-KB is used by the Operating System. Consider
three process of size 425-KB, 368-KB and 470-KB and these three process are loaded into the
memory. This leaves a hole at the end of the memory. That is too small for a fourth process. At
some point none of the process in main memory is ready. The operating system swaps out process-
2 which leaves sufficient room for new process of size 320-KB. Since process-4 is smaller then
process-2, another hole is created. Later a point is reached at which none of the processes in the
main memory is ready, but proces-2 is, so process-1 is swapped out and process-2 is swapped in
there. It will create another hole. In this way it will create lot of small holes in the memory system
which will lead to more memory wastage.
The effect of dynamic partitionining that creates more hole during the execution of processes is
shown in the Figure 3.21.