Docsity

Computer science short notes,questions, Exams of Computer Science

Toggle sidebar
bg1
1
OPERATING SYSTEMS
COMPUTER SYSTEM COMPONENTS
What is a system?
A system is the entire set of components, both computer related, and non-computer related, that
provides a service to a user. Or a system is a group of related parts/components that work together
as a unit to realize a common goal/function.
Functional Parts of a Digital Computer
MEMORY
FIXED BACKING
STORAGE
Control Unit
Arithmetic &
Logic Unit
Registers
PROCESSOR
REMOVABLE BACKING
STORAGE
INPUT
OUTPUT
Key
Data Flow
Control Flow
Program Flow
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24

Partial preview of the text

Download Computer science short notes,questions and more Exams Computer Science in PDF only on Docsity!

OPERATING SYSTEMS

COMPUTER SYSTEM COMPONENTS What is a system? A system is the entire set of components, both computer related, and non-computer related, that provides a service to a user. Or a system is a group of related parts/components that work together as a unit to realize a common goal/function.

Functional Parts of a Digital Computer

MEMORY

FIXED BACKING STORAGE

Control Unit Arithmetic & Logic Unit

Registers

PROCESSOR

REMOVABLE BACKING STORAGE

INPUT OUTPUT

Key Data Flow Control Flow Program Flow

Major categories of hardware components Input unit Output unit Storage unit ALU Control unit System unit o Mother Board o Processor – Control Unit, Arithmetic Unit, Registers o Memory (Primary) o Fixed Backing Storage (Secondary storage device)

INPUT DEVICES Input is any data and instructions entered into the memory of a computer. Input devices is any hardware component that allows users to enter data and instructions into a computer Instructions entered into the computer can be in form of: i) Programs – Series of instructions that tells a computer what to do how to do it. ii) Command – an instruction that causes a program to perform a specific action. Users issue command by typing or pressing keys on keyboard, click a mouse button, speaking into a microphone or touching an area of a screen. iii) User response – an instruction a user issues by replying to a question displayed by a program.

SYSTEM UNIT It is a case that contains electronic components of the computer used to process data. Many electric components and most storage devices are part of the system unit. Other devices such as keyboards, mouse, microphone, monitor, printer, and scanner are all connected to the system unit. Parts of the system unit include: a) Mother Board (System board) It is the main circuit board of the computer system unit. Many electronic components are attached to it. b) Processor (Central Processing Unit) Interprets and carries out the basic instructions that operate a computer. It impacts on overall computing power and manages most of a computer’s operations. Examples of Processor Manufacturers: Intel Corporation (Xeon MP, Itanium, Pentium, 80486, Celeron). AMD (Opteron, Athlon MP, Duron). Motorola (68040, 68030) Motorola/IBM(Power PC). Transmeta (Efficeon, Crusoe) Parts of a processor i) Control Unit (CU)

Volatile RAM (Random Access Memory) – Main memory which consists of memory chips that can read from and written to by the processor and other devices. The processor interprets and executes a program’s instructions while the program is in the RAM. RAM can accommodate multiple programs simultaneously. Examples of RAM include: Non – Volatile ROM (Read Only Memory) - are chips storing permanent data and instructions. Data on most ROM chips cannot be modified hence the name read only. Manufacturers of ROM chips often record data and instructions or information on chips (firmware).

SECONDARY STORAGE Storage holds data, instructions and information for future use. A storage medium also called secondary storage is the physical material on which a computer keeps data, instructions and information. Examples include: i) Floppy Disks (Magnetic Disks) ii) Hard Disks (Magnetic Disks) iii) Magnetic Tapes (Magnetic Disks) iv) Compact Disks (Optical Discs) v) Digital Versatile Disks (DVD) -(Optical Discs) vi) PC Cards vii) Flash Memory viii) Microfiche Capacity is the number of bytes (Characters) a storage medium can hold. Terms used by manufacturers to measure capacity are same as those used for memory. Typical sizes for devices include Floppy Disks – 1.44 Megabytes Hard Disks – 80 Gigabytes Flash Memory – 512 MB Compact Disc – 700 MB DVD – 4.7 GB Secondary Storages are used to supplement the Primary storage. Their typical uses include: a) Storing the operating system, Application software, user data and information

b) Software back ups c) Transportation of files

task Differentiate between primary and secondary storage

Magnetic Disks – use magnetic materials to store items such as data, instructions, and information on a disk’s surface. Depending on how the magnetic particles are aligned, they represent either a 0 bit or a 1 bit. Examples are floppy disks, Zip Disks, Hard Disks.

Optical Discs – Is a type of storage media that consists of a flat, round, portable disc made of metal, plastic, and lacquer that is written and read by a laser. They primarily store software, data, digital photographs, movies and music. Some optical discs are read only – meaning users cannot write (save) on media. Others are read/write – allows users to save on discs. Examples include: CD (Compact Discs), DVD (Digital Versatile Disc)/ (Digital Video Disc).

USB Flash Drives – is a flash memory storage device that plugs in a USB port on a computer or mobile device. They are convenient for mobile users because they are small and light weight enough to be transported in a pocket. Experts predict that USB flash drives will become the mobile user’s primary portable storage device, eventually making the floppy disk obsolete.

Assignment 2 Explain the following storage devices a) Smart Cards b) Microfilm and Microfiche c) PC Cards d) Magnetic Tapes

COMPUTER SOFTWARE

Software is a set of electronic instructions consisting of complex codes (also known as programs) that make the computer perform tasks. In other words, software tells the computer what to do. Some programs exist primarily for the computer's use and help the computer perform and manage its own tasks. Other types of programs exist primarily for the user and enable the computer to perform tasks, such as creating documents or drawing pictures. Computer software is divided into two major categories: System and application software.

SYSTEM SOFTWARE Consists of the programs that control and maintain the operating of the computer and its devices. It serves as an important interface between the user, application software and hardware. Types of system software are: a) Operating system b) Utility programs

Operating System – are a set of programs containing instructions that co-ordinate all the activities among computers hardware resources. Basic function of the operating system include:  Memory management  Process Management  File Management  Device Management  Providing security

Utility Programs – They are included with most operating systems and provide the following functions:  Managing files  Viewing images  Securing a computer from unauthorized access,  Uninstalling programs.  Scanning disks (deletes and corrects physical and logical problems on a hard disk and searches and removes unnecessary file).

 Disk Defragmenter – reorganizes the file sand unused space on a computer’s hard disk so that the operating system accesses data more quickly and programs run faster).  Diagnostic Utility – Compiles technical information about your computer’s hardware and certain system software programs and prepares a report outlining any identified problem.  Back up utility - allows users to copy or back up selected files or an entire hard disk to another storage medium.

Examples of operating system Category Operating System Names Stand alone DOS, Windows 3.X, Windows 95, Windows NT, Windows 98, Windows ME, Windows XP, Windows VISTA, Macintosh O/S, UNIX, LINUX Network Netware, Windows 2000 Server, Windows2003 Server, UNIX, LINUX, Solaris Embedded Windows CE, Windows Mobile, Palm O/S, Embedded LINUX, Symbian O/S.

What is an Operating System? A program that control the execution of programs and acts as an intermediary between application and the computer hardware. As an Intermediary, it provides an environment in which the user can execute programs. Operating system goals and objective:  To execute user programs and make solving user problems easier.  To make the computer system convenient to use.  To use the computer hardware in an efficient manner (optimal use of computing resources).  Ability to evolve ; An OS should be constructed in such a way as to permit the effective development, testing and introduction of a new system functions with our interfering with service.

Generic o/s – designed for use by a wide variety of computer architectures e.g. UNIX that runs on both Intel and Motorola Microprocessors Operating system functions a) Process Management Process - fundamental concept in OS a. Process is a program in execution. b. Process needs resources - CPU time, memory, files/data and I/O devices. OS is responsible for the following process management activities.  Process creation and deletion  Process suspension and resumption  Process synchronization and interprocess communication  Process interactions - deadlock detection, avoidance and correction

b) Main Memory Management Main Memory is an array of addressable words or bytes that is quickly accessible. Main Memory is volatile. OS is responsible for:  Allocate and deallocate memory to processes.  Managing multiple processes within memory - keep track of which parts of memory are used by which processes. Manage the sharing of memory between processes.  Determining which processes to load when memory becomes available.

c) File / Secondary storage Management Since primary storage is expensive and volatile, secondary storage is required for backup. Disk is the primary form of secondary storage. OS performs storage allocation, free-space management and disk scheduling.

d) Input /Output (Device) System management I/O system in the OS consists of

 Buffer caching and management  Device driver interface that abstracts device details  Drivers for specific hardware devices

e) Protection System (Security) Protection mechanisms control access of programs and processes to user and system resources. Protect user from himself, user from other users, system from users. Protection mechanisms must:  Distinguish between authorized and unauthorized use.  Specify access controls to be imposed on use.  Provide mechanisms for enforcement of access control.  Security mechanisms provide trust in system and privacy authentication, certification, encryption etc. f) File System Management File is a collection of related information defined by creator - represents programs and data. OS is responsible for  File creation and deletion  Directory creation and deletion  Supporting primitives for file/directory manipulation.  Mapping files to disks (secondary storage).  Backup files on archival media (tapes).

Operating System DefinitionsResource Allocator – OS manages and allocates resources (hardware & software-CPU, memory & file storage space, I/O devices etc) to specific programs and users. Incase of conflicting requests for resources, OS decides which requests are allocated resources to ensure fair & efficient computer usage.

OPERATING SYSTEM DESIGN AND IMPLEMENTATION

Design and Implementation of OS is not “solvable”, but some approaches have proven successful. Internal structure of different Operating Systems can vary widely. The design starts by defining goals and specifications and this is affected by choice of hardware and type of system. In guiding the design operating systems the user and system goals are taken into consideration.  User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast.  System Goals – operating systems should be easy to design, implement, and maintain, as well as flexible, reliable, error- free, and efficient Important principles to separate during design are:  Policy: What will be done? (decide what will be done)  Mechanism: How to do it? (determine how to do something) The separation of policy from mechanism is a very important principle since it allows maximum flexibility if policy decisions are to be changed later.

Types of structures a) Simple Structure / Monolithic systems It has also been subtitled “The Big Mess” i.e. no structure where the o/s is viewed as a collection of procedures which can call each other. There is no information hiding (procedures can view each other) and basically suggests a basic structure for the o/s which includes:  Main Program – invokes service procedure  A set of service procedures – which carry system calls.  A set of utility procedures that help the service procedures Example of MS DOS MS-DOS – written to provide the most functionality in the least space. It is not divided into modules. Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated (no information hiding).

b) Layered Approach The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface. With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers.

Examples of layers developed by Dijkstra (1968) in Netherlands Layer Function (5) Operator (4) User Programs (3) Input / Output Management (2) Operations / Process communication (1) Memory and Device Management (0) Process allocation and multiprogramming

provide virtual card readers and virtual line printers. A normal user time-sharing terminal serves as the virtual machine operator’s console

(a) Non virtual machine (b) virtual machine The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines. This isolation, however, permits no direct sharing of resources. A virtual-machine system is a perfect vehicle for operating-systems research and development. System development is done on the virtual machine, instead of on a physical machine and so does not disrupt normal system operation. The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine. Example is LINUX implementation. The technique is also implemented in the Java Virtual Machine.

f) Exokernels Gives each user a clone of actual computer, but with a subset of resources. Thus one Virtual Machine might get disk blocks 0 to 1023, the next one might get block 1024 to 2047 and so on. At bottom layer a kernel mode program runs (exokernel) which allocates resources to V.M and monitors utilization.

g) Client-Server Model / Microkernel System Structure Involves moving code to higher levels even further and remove as much as possible from the o/s leaving a minimal kernel i.e. implementing most of the o/s system functions in user processes (client process sends a request to server process).

The kernel handles communication between clients and servers. The server processes run as user mode processes and no in kernel mode, they do not have direct access to the hardware (hard for hardware to crash). It has also been adapted to distributed systems.

Client Process

Client Process

Process Server

Terminal Server Kernel Process

..... ServerFile^ Memory Server User Mode

Kernel Mode

Client Kernel

Machine 1 File Server Kernel

Machine 2

Message from client to server

NETWORK

Diagram of process state

INTER-PROCESS COMMUNICATION O/s must provide inter-process communication facility (IPC) which provides a mechanism to allow processes to communicate and to synchronize their actions to prevent Race conditions (a condition where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place).

To guard against this mechanisms are necessary to ensure that only one process at a time can be manipulating the date. Some of this mechanisms / techniques include:

Critical Section Problem It is a segment of code in which a process may be changing common variables, updating a table, writing a file etc. Each process has its critical section while the other portion is referred to as Reminder section.

The important feature of the system is that when one has process is executing in its critical section no other process is to be allowed to execute its critical section. Each process must request permission to enter its critical section. A solution to critical section problem must satisfy the following: i) Mutual Exclusion – If one process is executing its critical section then no other process can be executing in their critical section. ii) Progress – If no process is executing in its critical section and there exists some processes that wish to enter critical sections then those processes that are not executing in their remainder section can be allowed.

iii) Bounded Waiting – There must exist a bound on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted (Prevents Bus waiting). Busy waiting occurs when one process is being executed in its critical section and process 2 tests to confirm if process 1 is through. It is only acceptable technique when the anticipated waits are brief; otherwise it could waste CPU cycles.

Techniques used to handle Critical section problem

1. Semaphores The fundamental principle is this: 2 or more processes can operate by means of simple signals, such that a process can be forced to stop at a specified place until it has received a special signal. Any complex coordinative requirement can be satisfied by the appropriate structure of signals. For signaling special variables called semaphores are used: To transmit a signal via semaphores, a process executes the primitive wait P(s); if the corresponding signal V(s) has not yet been transmitted the process is suspended until transmission takes place.

To achieve the desired effect we can view the semaphore as a variable that has an integer value upon which 3 operations are defined a) A semaphore may be initialized to a non negative value b) The wait operation decrements these semaphore value. If the value becomes negative the process executing the wait is blocked. c) The signal operation increments the semaphore value. If the value is not positive then a process is blocked by await operation is unblocked A binary semaphore accepts only 2 values 0 or 1. For both semaphore and binary semaphore a queue is used to hold processes waiting on the semaphore. A strong semaphore has a mechanism of removing processes from a queue e.g. FIFO policy. A weak semaphore doesn’t specify the order in which processes are removed from the queue. Example of implementation: wait (S); Critical Section signal (S);