Saturday, 17 October 2020

Block Diagram of Computer and Functions

 

What is a Computer ?

We can define a computer as a “programmable electronic device designed to accept data, perform prescribed mathematical and logical operations at high speed, and display the results of these operations”. A computer is a device that operates upon data. Data can be defined as a collection of facts and figures. Data can be anything like bio data of applicants when computer is used for short listed candidates for recruiting; marks obtained by students in various subjects when used for preparing results; details of passengers when used for making airline or railway reservations; or a number of different parameters when used for solving scientific research problems, etc.

 

Hence, data comes in various shapes and sizes depending upon the type of computer application. A computer can store, process, and retrieve data as and when desired. The fact that computers process data is so fundamental that many people have started calling it a data processor.

 

The activity of processing data using a computer is called as data processing. Data processing consists of three sub activities:

 

1.    Capturing input data

2.    Manipulating the data and;

3.    Managing output results.

 

As used in data processing, information is data arranged in an order and form that is useful two people receiving it. Hence, data is a raw material, used as input to data processing and information is processed data obtained as output of data processing.

 

No matter what shape and size of computer we are talking about, all computer systems perform the following operations for converting the input data into useful information and present it to the user. These operations are:

 

  1. Inputting- process of entering data and instructions into a computer system.
  2. Storing- saving data and instructions to make them more readily available for initial or additional processing as and when required.
  3. Processing- performing arithmetic operations (add, subtract, multiply, divide, etc.) or logical operations (comparison like equal to, less than, greater than, etc.) on data to convert them into useful information.
  4. Outputting- process of producing useful information for use, such as printed report or visual display.
  5. Controlling- directing the manner and sequence in which the above operations are performed.

 Block Diagram of a Computer:

The internal architecture of computers differs from one system model to another. However, basic organization remains the same for all computer system. Following figure shows a block diagram basic computer organization.

 

The solid lines indicate flow of instruction and data, and dotted lines represent control exercised by control unit. It displays five major building blocks (functional units) of a digital computer system. These units correspond to the five basic operations perform by all computer systems.


Block Diagram of Computer

Fig: Block diagram of a computer system


The functions of the 5 major building blocks can be described as follows:

Input Unit:

· Data and instructions must enter a computer system before the computer can perform any computation on the supplied data.

· The input unit that links a computer with its external environment performs this task.

· Data and instructions enter a computer through an input unit in a form that depends upon the input device used. 

· However, a computer's memory is designed to accept input in binary code and hence all input devices must transform input signals to binary codes.

· Units called input interfaces accomplish this transformation. Input interfaces match the unique physical or electrical characteristics of input devices to the requirements of a computer system.

 

· An input unit performs following functions:

  1. It accepts or reads instructions and data from outside world.
  2. It converts these instructions and data in a computer acceptable form.
  3. It supplies the converted instructions and data to computer system for further processing.

Output Unit:

· An output unit performs the reverse operation of that of an input unit.

· It supplies information obtained from data processing to outside world. Hence, it links a computer with its external environment.

· As computers work with binary code, results produced are also in binary form. Therefore, before supplying the results to outside world, the system must convert them to human readable form.

· Units called output interface is accomplish this task. Output interfaces match the unique physical or electrical characteristics of output devices to the requirements of an external environment.

 

· An output unit performs the following functions:

  1. It accepts the results produced by a computer, which are in coded form and hence, we cannot easily understand them.
  2. It converts these ordered results to human readable form.
  3. It supplies the converted results to outside world.


Storage Unit:

· Data and instructions entered into a computer system through input units have to be stored inside the computer before actual processing starts.

· Similarly, results produced by a computer after processing have to be kept somewhere inside the computer system before being passed on to an output unit.

· Moreover, a computer must also preserve intermediate results for on-going processing.

· Storage unit of a computer system caters to all these needs. It provides space for storing and data and instructions, intermediate results, and results for output.

 

· The storage unit stores:

  1. Data and instructions required for processing (received from input devices).
  2. Intermediate results of processing.
  3. Results for output, before they are released to an output device.

 

· Storage unit of all computers is comprised of following two types of storage:

 

1.    Primary Storage:

· Primary storage of a computer is also known as its main memory.

· It is used to hold pieces of program instructions and data, intermediate results of processing, and recently produced results of those jobs on which the computer is currently working.

· These pieces of information are represented electronically in the main memory chip’s circuitry and while it remains in the main memory, Central Processing Unit can access it directly at a very fast speed.

· However, primary storage can hold information only while computer system is on. As soon as the computer system switches off or resets, the information held in primary storage is erased.

· Moreover, primary storage normally has limited storage capacity because it is very expensive.

· Primary storage of modern computer systems is made of semiconductor devices. Example: Random Access Memory (RAM).

 

2.    Secondary Storage:

· Secondary storage of a computer is also known as its auxiliary storage.

· It is used to take care of the limitations of primary storage; i.e. it supplements storage capacity and the volatile characteristics of primary storage.

· This is because secondary storage is much cheaper than primary storage and it can retain information even when a computer system switches off or resets.

· Secondary storage holds the program instructions, data, and information of those jobs on which the computer system is currently not working but needs to hold them for processing later.

· Magnetic disk is the most commonly used secondary storage medium.


Arithmetic Logic Unit (ALU):

· An arithmetic logic unit (ALU) of a computer system is the place where actual execution of instructions takes place during the processing operation.

· To be more precise, calculations are performed and all comparisons are made in the ALU.

· Data and instructions stored in primary storage before processing are transferred as and when needed to the ALU where processing takes place.

· Intermediate results generated in the ALU are temporarily transferred back to primary storage until needed later.

· Hence, data may move from primary storage to ALU and back again to storage many times before processing is over.

· The type and number of arithmetic and logic operations that a computer can perform is determined by the engineering design of its ALU.

· However, almost all ALUs are designed to perform the four basic arithmetic operations (add, subtract, multiply, and divide) and logic operations or comparisons such as less than, equal to, and greater than.

 

Control Unit (CU):

· The control unit does not perform any actual processing on data.

· The control unit acts as a central nervous system for other components of a computer system.

· It manages and coordinates the entire computer system.

· It obtains instructions from the program stored in main memory, interprets the instructions, and issues signals causing other units of the system to execute them.



Central Processing Unit (CPU):

· Control unit (CU) and arithmetic logic unit (ALU) of a computer system are together known as the central Processing Unit (CPU).

· The CPU is the brain of a computer system.

· All major calculations and comparisons take place inside the CPU and the CPU is responsible for activating and controlling the operations of other units of the computer system.


CPU as ALU and CU

Fig: CPU as ALU and CU

 

 The System Concept:

· A system is a group of integrated parts that have a common purpose of achieving some objective(s).

· Hence, the system must have the following three characteristics:

  1. It must have a more than one element.
  2. All its elements must be related logically.
  3. All its elements must be controlled in a manner to achieve the system goal.

 

· As computer comprises of integrated components (input unit, output unit, storage unit and CPU) that work together to perform the steps called for in a program, it is a system.

· Its input and output units cannot function until they receive signals from the CPU. Similarly, the storage unit are the CPU alone is of no use.

· Hence, the usefulness of each unit depends on other units and is realizable only when all units are put together (integrated) to form a system.


Friday, 18 September 2020

Round Robin (RR) CPU Scheduling Algorithm

 Round Robin Scheduling (RR):

The time sharing systems uses the Round Robin algorithm. The use of a small time quantum allows Round Robin to provide good response time. It is a preemptive algorithm.

 

CPU selects the process from the ready queue. To implement RR scheduling, ready queue is maintained as a FIFO queue. New processes are added to the tail of the ready queue. The CPU scheduler picks the first process from the ready queue, set a timer to interrupt after one time quantum and dispatches the process.

 

With RR algorithm, the principal design issue is the length of the time quantum or time slice to be used. If the time quantum is very short, then short processes will move through the system relatively quickly. It increases the processing overhead involved in handling the clock interrupt and performing the scheduling and dispatch function. So, a very short time quantum should be avoided.

 

Consider the set of processes with the burst time in milliseconds. All the processes arrive at time 0. The Gantt chart, waiting time and so on are as follows:


Process

Burst time

P1

3

P2

6

P3

4

P4

2


RR Gantt chart


Waiting time:

Process

Waiting time

P1

0 + 6 = 6

P2

2 + 5 + 2 = 9

P3

4 + 5 =9

P4

6 = 6


RR avg waiting time


Turnaround time:

 It is the sum of burst time + waiting time of each process.

 

Process

Turnaround time

P1

3 + 6 = 9

P2

6 + 9 = 15

P3

4 + 9 = 13

P4

2 + 6 = 8



RR avg turnaround time



Priority CPU Scheduling Algorithm

 

Priority Scheduling:

CPU is allocated to the highest priority of the process from the ready queue. Each process has a special number associated with called as priority number. If two or more processes have the same priority, then FCFS algorithm is applied for solving the tie. 

 

The values of priority are not fixed. In some systems, lower value denotes a lower priority, whereas in some systems lower value denotes higher priorities. In our example, we are considering low numbers have the higher priority.


Priority scheduling can be preemptive or non-preemptive. Priority of the process can be defined either internally or externally. Internal priority considers the time limits, number of open files, use of memory and use of IO devices. External priorities are set by using external parameter of the process like importance of a process, cost of process, etc.

 

When the process arrives at the ready queue, its priority is compared with the priority of the currently running process. A non preemptive priority algorithm will simply put the new process at the head of the ready queue.

 

A preemptive priority scheduling algorithm will preempt the CPU if priority of the newly arrived process is higher than the priority of the currently running process. In this, current executing process will change the state from running to ready. In non preemptive scheduling algorithm, currently executing process will not change state.

 

Consider the following set of processes with the burst time in milliseconds. Arrival time of the process is 0.

 

Process

Burst time

Priority

P1

3

2

P2

6

4

P3

4

1

P4

2

3

 

Processes arrive in the order P1, P2, P3, and P4. Gantt chart, waiting time and turnaround time for priority scheduling algorithm are as follows:

Priority Gantt chart


Waiting time:

Process

Waiting time

P1

4

P2

9

P3

0

P4

7


Priority avg waiting time

Turnaround time:

 It is the sum of burst time + waiting time of each process.

 

Process

Turnaround time

P1

3 + 4 = 7

P2

6 + 9 = 15

P3

4 + 0 = 4

P4

2 + 7 = 9

 

Priority avg turnaround time

Priority scheduling algorithm can leave some low-priority processes waiting indefinitely for the CPU. This problem is called starvation. Priority scheduling algorithm faces the starvation problem. Starvation problem is solved by using aging technique. In aging technique, priority of the processes will increase which are waiting for a longer time in the ready queue.