Components of A Computer System
Components of A Computer System
computer System
CPU
The CPU carries out all operations through the three
main steps of the instruction cycle: fetch, decode, and
execute.
Fetch
Decode
Execute.
Arithmetic Logic Unit
1. Cache memory
• Semiconductor memory
• High speed semiconductor memory. Volatile memory
• It acts as a buffer between CPU and main memory
• The main purpose of a cache is to hold the frequently used data and programs.
Advantages
Cache memory is faster than main memory.
It consumes less access time as compared to main memory.
It stores the program that can be executed within a short period of time.
It stores data for temporary use.
Disadvantages
Cache memory has limited capacity.
It is very expensive.
2. Primary (Main) memory
• Semiconductor memory
• Main memory holds currently processed data and instructions.
• Faster than secondary memory
• Computer can not run without primary memory.
2 categories:
I. RAM (Random Access Memory): primary volatile memory
II. ROM (Read Only Memory): primary non-volatile memory
3. Secondary memory
• Magnetic or optical memory
• External and/or non-volatile memory
• Slower than main memory
• Used to store data/information permanently
• CPU accesses secondary memory through main memory
Storage
• Storage is a mechanism which allows computer to retain data permanently.
• Memory is used to store data temporarily. When we save file it is copied from memory to storage
• We can choose internal or external storage which can’t be done with memory.
• Internal storage is part of computers hardware while external storage is separate device plugged into
computer.
Memory Hierarchy
Operating System
• OS is an interface between user and computer hardware. It performs all basic tasks.
• The primary purposes of an Operating System is to enable applications (software’s) to interact with a
computer's hardware and to manage a system's hardware and software resources.
• The application programs make use of the operating system by making requests for services through a defined
application program interface (API).
• Users can directly interact with OS through UI or CLI (command line interface).
• Once installed OS relies on drivers to provide OS services to hardware.
• The kernel is the software that contains the operating system’s core components.
Functions of OS
• Processor management : allocates various jobs to processor and ensure that each process receives enough time
from the processor to function properly.
• Memory management: allocation and deallocation of memory to processes.
• File management: keeps track of information regarding the creation, deletion, transfer, copy, and storage of files
in an organized way.
• Device management: Controls I/O devices.
• Security:
Protection against unauthorized access through login.
Protection against intrusion by keeping Firewall active.
Protecting the system memory against malicious access.
Displaying messages related to system vulnerabilities
• Error detection
• Job scheduling: ordering (multitasking OS)
Parts of OS
Types of OS
• Batch OS
• Distributed OS
• Multitasking OS / Time Sharing OS
• Network OS
• Real time OS
• Mobile OS
Assembler
• A computer program that converts basic instructions to pattern of bits
• Assembly language machine language
• Today, assembler programming is used only where very efficient control over processor operations is needed.
• Assembly language enables developers to access, operate and manage the computer’s hardware
Compiler
• Converts high level language code to machine language code.
• Compiler considers entire code and converts it whereas assembler converts it line by line
• There are 7 phases of the compiler:
1. Lexical Analysis
2. Syntax analysis
3. Semantic analysis
4. Intermediate code generation
5. Code optimization
6. Code generation
7. Error handling
Interpreter
• Apart from compiler and assembler interpreter is the software which performs task of converting high level
language code to machine language.
• The basic difference is that a compiler system generates a stand-alone machine code program, while an interpreter
system instead performs the actions described by the high-level program.
• Execution is done line by line or statement by statement.
• In most cases, a compiler is preferable since its output runs much faster compared to a line-by-line interpretation.
• Interpreter is used during development phase to test the outcome of a small chunk of code rather than checking
the entire program.
• Programming languages that use interpreters include Python, Ruby, and JavaScript, while programming languages
that use compilers include Java, C++, and C.
Compiler vs Interpreter vs Assembler
Memory requires requires less
Memory requires requires less
more memorymore memory memory memory
Linker
• Linker is a system program which combines one or more object files generated by assembler or compiler into
an executable file.
• Linking is performed at both compile time, when the source code is translated into machine code and load
time, when the program is loaded into memory by the loader.
• Linker can also take objects from library.
• Types of linking:
Static linking:
• Linking is performed during the compile time i.e. before the execution of file.
• Two major tasks are performed by the static linker are:
o Symbol resolution: In this, each symbol has a predefined task, and it associates each symbol
exactly with one symbol definition from which they belong to.
o Relocation: It relocates code and data section and modifies the symbol references to the
relocated memory locations.
• As the linker copies all library routines used in the program into executable image it requires more
memory space. As it does not require the presence of library on the system when it is run, so it is
faster and more portable. No failure chance and less error chance.
Linker…
Dynamic linking:
• Linking is performed during run time. This linking is accomplished by placing the name
of a shareable library in the executable image. More chances of errors and failures. It
requires less memory space as multiple programs can share a single copy of the library.
More prone to errors.
• Advantages of dynamic linking:
o Frequently used libraries are stored at one location, no need to duplicate them with
each executable file. Saves memory and disk space.
o If library is modified automatically, it affects all programs associated with it. No
need to link them again.
• Disadvantages:
o If updated library is not backword compatible then it will break executables.
Loader
• It is special program that takes input of executable files from linker, loads it to main memory, and prepares
this code for execution by computer.
• Loader reads the executable files and stores the instructions into RAM.
• Loader allocates memory space to program.
• It settles down symbolic reference between objects.
• It is in charge of loading programs and libraries in operating system.
• The embedded computer systems don’t have loaders. In them, code is executed through ROM.
Unit I : Introduction to Computer Algorithms and Programming
Components of a computer system:
• CPU – 3 main steps of instruction cycle.
• Control Unit
• ALU
• I/O devices
• Memory
• Cache
• Primary
• Secondary
• Memory hierarchy
• Storage
• OS
• What is OS?
• Functions of OS
• Parts of OS
• Types of OS
• Assembler
• Compiler
• Interpreter
• Linker
• loader
TEXT BOOKS:
1. B. A. Forouzan and R. F. Gilberg -Programming & Data Structures, 3rd Ed., Cengage
Learning`
2. Byron Gottfried - Schaum’s Outline of Programming with C, McGraw-Hill
REFERENCE BOOKS:
1. Ajay Mittal - Programming in C: A practical approach, Pearson Education, 2010
2. Kernighan Brian W. and Ritchie Dennis M.- The C programming, Pearson Education.
3. J. R. Hanlyand, E. B. Koffman -Problem Solving and Program Design, 5th Ed., Pearson
Education.
4. H. Cheng - C for Engineers and Scientists, McGraw-Hill International Edition
5. V. Rajaraman - Computer Basics and C Programming, PHI Learning, 2015.