0% found this document useful (0 votes)
2K views749 pages

Computer Science Level 6 Learning Guide

The document is a Learning Guide for Computer Science Level 6 developed by the TVET Curriculum Development, Assessment and Certification Council (CDACC) in Kenya. It emphasizes the importance of competency-based education and training (CBET) to address the skill gap in the workforce and align with Kenya's Vision 2030 and Sustainable Development Goals. The guide includes structured learning outcomes and activities across various computer science topics to enhance the delivery of the curriculum and support the development of skilled professionals in the sector.

Uploaded by

felix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views749 pages

Computer Science Level 6 Learning Guide

The document is a Learning Guide for Computer Science Level 6 developed by the TVET Curriculum Development, Assessment and Certification Council (CDACC) in Kenya. It emphasizes the importance of competency-based education and training (CBET) to address the skill gap in the workforce and align with Kenya's Vision 2030 and Sustainable Development Goals. The guide includes structured learning outcomes and activities across various computer science topics to enhance the delivery of the curriculum and support the development of skilled professionals in the sector.

Uploaded by

felix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 749

REPUBLIC OF KENYA

LEARNING GUIDE

FOR

COMPUTER SCIENCE

LEVEL 6

TVET CDACC
P.O. BOX 15745-00100
NAIROBI
First published 2020
Copyright TVET CDACC

All rights reserved. No part of this learning guide may be reproduced, distributed, or transmitted
in any form or by any means, including photocopying, recording, or other electronic or mechanical
methods without the prior written permission of the TVET CDACC, except in the case of brief
quotations embodied in critical reviews and certain other non-commercial uses permitted by
copyright law. For permission requests, write to the Council Secretary/CEO, at the address below:

Council Secretary/CEO
TVET Curriculum Development, Assessment and Certification Council
P.O. Box 15745–00100
Nairobi, Kenya
Email: [email protected]

i
FOREWORD

The provision of quality education and training is fundamental to the Government’s overall
strategy for social economic development. Quality education and training will contribute to
achievement of Kenya’s development blueprint and sustainable development goals. This can only
be addressed if the current skill gap in the world of work is critically taken into consideration.

Reforms in the education sector are necessary for the achievement of Kenya Vision 2030 and
meeting the provisions of the Constitution of Kenya 2010. The education sector has to be aligned
to the Constitution and this has triggered the formulation of the Policy Framework for Reforming
Education and Training (Sessional Paper No. 4 of 2016). A key provision of this policy is the
radical change in the design and delivery of the TVET training which is the key to unlocking the
country’s potential in industrialization. This policy document requires that training in TVET be
Competency Based, Curriculum development be industry led, certification be based on
demonstration and mastery of competence and mode of delivery allows for multiple entry and exit
in TVET programs.

These reforms demand that industry takes a leading role in TVET curriculum development to
ensure the curriculum addresses and responds to its competence needs. The learning guide in
Computer Science enhances a harmonized delivery the competency-based curriculum for
Computer Science Level 6.

It is my conviction that this learning guide will play a critical role towards supporting the
development of competent human resource for the Computer Science sector’s growth and
sustainable development.

PRINCIPAL SECRETARY, VOCATIONAL AND TECHNICAL TRAINING


MINISTRY OF EDUCATION

PREFACE

Kenya Vision 2030 is anticipated to transform the country into a newly industrialized, “middle-
income country providing a high-quality life to all its citizens by the year 2030”. The Sustainable

ii
Development Goals (SDGs) further affirm that the manufacturing sector is an important driver to
economic development. The SDG nine that focuses on Building resilient infrastructures,
promoting sustainable industrialization and innovation can only be attained if the curriculum
focuses on skill acquisition and mastery. Kenya intends to create a globally competitive and
adaptive human resource base to meet the requirements of a rapidly industrializing economy
through life-long education and training. TVET has a responsibility of facilitating the process of
inculcating knowledge, skills and attitudes necessary for catapulting the nation to a globally
competitive country, hence the paradigm shift to embrace Competency Based Education and
Training (CBET). The Technical and Vocational Education and Training Act No. 29 of 2013 and
the Sessional Paper No. 4 of 2016 on Reforming Education and Training in Kenya, emphasized
the need to reform curriculum development, assessment and certification to respond to the unique
needs of the industry. This called for a shift to CBET to address the mismatch between skills
acquired through training and skills needed by industry as well as increase the global
competitiveness of Kenyan labor force.

The TVET Curriculum Development, Assessment and Certification Council (TVET CDACC), in
conjunction with TVET training institution trainers developed the Occupational Standards which
was the basis of developing competency-based curriculum and assessment of an individual for
competence certification for a Computer Science Level 6. The learning guide is geared towards
promoting efficiency in the delivery of curriculum.

The learning guide is designed and organized with clear and interactive learning activities for each
learning outcome of a unit of competency. The guide further provides information sheet, self-
assessment, tools, equipment’s, supplies, and materials and references.

I am grateful to the Council Members, Council Secretariat, Computer Science experts and all those
who participated in the development of this learning guide.

Prof. CHARLES M. M. ONDIEKI, PhD, FIET (K), Con. EngTech. CHAIRMAN,


TVET CDACC

ACKNOWLEDGEMENT

This learning guide has been designed to support and enhance uniformity, standardization and
coherence in implementing TVET Competency Based Education and training in Kenya. In
developing the learning guide, significant involvement and support was received from various
organizations.

iii
I recognize with appreciation the critical role of the participants drawn from technical training
institutes, universities and private sector in ensuring that this learning guide is in-line with the
competencies required by the industry as stipulated in the occupational standards and curriculum.
I also thank all stakeholders in the Computer Science sector for their valuable input and all those
who participated in the process of developing this learning guide.

I am convinced that this learning guide will go a long way in ensuring that workers in Computer
Science sector acquire competencies that will enable them to perform their work more efficiently
and make them enjoy competitive advantage in the world of work

DR. LAWRENCE GUANTAI M’ITONGA, PhD


COUNCIL SECRETARY/CEO
TVET CDACC

iv
ACRONYMS

BC: Basic competency


CBET: Competency Based Education and Training
CC: Common competency
CR: Core Competency
CU: Curriculum
CS: Computer Science
KCSE: Kenya Certificate of Secondary Education
KNQA: Kenya National Qualifications Authority
SSAC: Sector Skills Advisory Committee
TVET: Technical and Vocational Education and Training
TVET CDACC: TVET Curriculum Development, Assessment and Certification Council
AI – Artificial Intelligence
ROM – Read Only Memory
RAM – Random Access Memory
LAN – Local Area Network
WAN – Wide Area Network
ASCII – American Standard Code for Information Interchange
BIOS – Basic Input Output System
CASE – Computer Aided Software Engineering
SDLC – Software Development Life Cycle
DDL – Data Definition Language
GB – Gigabytes
HTML- Hyper Text Mark-up Language

v
TABLE OF CONTENTS
FOREWORD ................................................................................................................................ ii
PREFACE ..................................................................................................................................... ii
ACKNOWLEDGEMENT .......................................................................................................... iii
ACRONYMS ................................................................................................................................. v
TABLE OF CONTENTS ............................................................................................................ vi
LIST OF TABLES ........................................................................................................................ x
LIST OF FIGURES ..................................................................................................................... xi
LIST OF GRAPHS .................................................................................................................... xiv
CHAPTER 1: INTRODUCTION ............................................................................................. 1
1.1 Background Information ................................................................................................. 1
1.2 The Purpose of Developing the Trainee Guide............................................................... 1
1.3 Layout of the Learning Guide ......................................................................................... 1
CHAPTER 2: COMPUTER ORGANISATION AND ARCHITECTURE ............................ 4
2.1 Introduction ..................................................................................................................... 4
2.2 Performance Standard ..................................................................................................... 4
2.3 Learning Outcomes ......................................................................................................... 4
2.3.1 List of Learning Outcomes ......................................................................................... 4
2.3.2 Learning Outcome 1: Understand Principles of Computer Organization and Design5
2.3.3 Learning Outcome 2: Understand Central Processing Unit functions ..................... 13
2.3.4 Learning Outcome 3: Understand Computer Memory Organization .......................... 21
2.3.5 Learning Outcome 4: Understand Input-Output functions ....................................... 33
2.3.6 Learning Outcome 5: Understand computer arithmetic and logic ........................... 49
CHAPTER 3: OPERATING SYSTEMS ................................................................................. 70
3.1 Introduction ......................................................................................................................... 70
3.2 Performance Standard ......................................................................................................... 70
3.3. Learning Outcomes ............................................................................................................ 70
3.3.1. List of learning outcomes ............................................................................................ 70
3.3.2 Learning Outcome No 1: Understand fundamentals of operating systems .............. 71
3.3.3 Learning Outcome 2: Understand Process Management ......................................... 89
3.3.4 Learning Outcome 3: Understand Memory Management ......................................... 111
3.3.5 Learning Outcome 4: Understand Input and Output Management ....................... 126
3.3.6 Learning Outcome 5. Understand File Management and local policy settings ........ 158
CHAPTER 4: MATHEMATICS FOR COMPUTER SCIENCE ........................................ 170
4.1 Introduction ....................................................................................................................... 170

vi
4.2 Performance Standard ....................................................................................................... 170
4.3 Learning Outcomes ........................................................................................................... 170
4.3.1 List of Learning Outcomes ........................................................................................ 170
4.3.2 Learning Outcome 1: Understand Linear Algebra ..................................................... 172
4.3.3 Learning outcome 2: Understand Boolean Algebra ................................................... 183
4.3.4 Learning outcome 3: Understand Set Theory ............................................................ 192
4.3.5 Learning outcome 4: Understand Calculus ................................................................ 199
4.3.6 Learning outcome 5: Understand Probability and Statistics ...................................... 211
CHAPTER 5: FUNDAMENTALS OF PROGRAMMING .................................................. 222
5.1 Introduction ....................................................................................................................... 222
5.2 Performance Standard ....................................................................................................... 222
5.3 Learning Outcomes ....................................................................................................... 222
5.3.1 List of Learning Outcomes ........................................................................................ 222
5.3.2 Learning Outcome 1: Understand programming concepts ........................................ 223
5.3.3 Learning outcome 2: Understand the Java Environment ........................................... 227
5.3.4 Learning outcome 3: Perform Data Operations ........................................................ 241
5.3.5 Learning outcome 4: Use Control Statements ........................................................... 253
262
5.3.6 Learning Outcome 5: Use Methods .......................................................................... 263
5.3.7 Learning Outcome 6: Understand Object Oriented Programming ............................ 272
CHAPTER 6: DATABASE MANAGEMENT SKILLS ....................................................... 279
6.1 Introduction ....................................................................................................................... 279
6.2 Performance Standard ....................................................................................................... 279
6.3 Learning Outcomes ........................................................................................................... 279
6.3.1 List of Learning Outcomes ........................................................................................ 279
6.3.2 Learning Outcome 1: Understand database fundamentals ......................................... 280
6.3.3 Learning Outcome 2: Design a database.................................................................... 310
6.3.4 Learning Outcome 3: Use Structured Query Language (SQL).................................. 330
6.3.5 Learning Outcome 4: Understand design of object oriented databases ..................... 357
6.3.6 Learning Outcome 5: Understand indexing and hashing ........................................... 371
6.3.7 Learning Outcome 6: Understand Database applications .......................................... 377
CHAPTER 7: INFORMATION SYSTEMS .......................................................................... 392
7.1 Introduction ....................................................................................................................... 392

vii
7.2 Performance Standard ....................................................................................................... 392
7.3 Learning Outcomes ........................................................................................................... 392
7.3.1 List of Learning Outcomes ........................................................................................ 392
7.3.2 Learning Outcome 1: Understand fundamentals of Information Systems ................. 393
7.3.3 Learning outcome 2: Understand the Software Development Process ...................... 400
7.3.4 Learning outcome 3: Demonstrate Human Computer Interaction Principles ............ 412
7.3.5 Learning outcome 4: Understand the VB.NET programming environment .............. 417
7.3.6 Learning outcome 5: Develop and test a VB.NET application .................................. 427
CHAPTER 8: NETWORKING AND DISTRIBUTED SYSTEMS..................................... 448
8.1 Introduction ....................................................................................................................... 448
8.2 Performance Standard ....................................................................................................... 448
8.3 Learning Outcomes ........................................................................................................... 448
8.3.1 List of Learning Outcomes ........................................................................................ 448
8.3.2 Learning Outcome 1: Understand networking and distributed systems concepts ..... 449
8.3.3 Learning Outcome 2: Understand Distributed Systems Architectures ...................... 476
8.3.4 Learning Outcome 3: Understand Distributed Processing and File Management ..... 485
8.3.5 Learning Outcome 4: Set up a Network in a Distributed Environment ..................... 492
8.3.6 Learning Outcome 5: Understand Data Communication Standards and IP Addressing
............................................................................................................................................. 506
8.3.7 Learning Outcome 6: Troubleshoot a Network ......................................................... 517
CHAPTER 9: ARTIFICIAL INTELLIGENCE ................................................................... 530
9.1 Introduction ....................................................................................................................... 530
9.2 Performance Standard ....................................................................................................... 530
9.3 Learning Outcomes ........................................................................................................... 530
9.3.1 List of Learning Outcomes ............................................................................................ 530
9.3.2 Learning Outcome 1: Understand Artificial Intelligence fundamentals .................... 531

............................................................................................................................... 536
9.3.3 Learning outcome 2: Understand problem solving techniques .................................. 538
9.3.4 Learning outcome 3: Understand Python programming environment ....................... 549
9.3.5 Learning outcome 4: Develop Artificial Intelligence programs using Python .......... 574
CHAPTER 10: ALGORITHMS AND DATA STRUCTURES ........................................... 581
10.1 Introduction ................................................................................................................. 581

viii
10.2 Performance Standard ..................................................................................................... 581
10.3 Learning Outcomes ......................................................................................................... 581
10.3.1 List of Learning Outcomes ...................................................................................... 581
10.3.2 Learning outcome 1: Understand fundamental principles of algorithms ................. 582
10.3.3 Learning Outcome 2: Understand fundamental concepts of data structures ........ 589
10.3.4 Learning Outcome 3: Understand Linked lists ..................................................... 601
10.3.5 Learning Outcome 4: Understand Stacks and Queues .......................................... 610
10.3.6 Learning Outcome 5: Understand Search Techniques.......................................... 619
CHAPTER 11: WEB DESIGN SKILLS ................................................................................ 631
11.1 Introduction ................................................................................................................. 631
11.2 Performance Standard ................................................................................................. 631
11.3 Learning Outcomes ..................................................................................................... 631
11.3.1 List of Learning Outcomes ................................................................................... 631
11.3.2 Learning Outcome 1: Understand HTML basics .................................................. 632
11.3.3 Learning Outcome 2: Use HTML Elements ......................................................... 636
11.3.4 Learning Outcome 3: Demonstrate Web Page Formatting ................................... 641
11.3.5 Learning Outcome 4: Apply Styles....................................................................... 647
11.3.6 Learning Outcome 5: Understand JavaScript ....................................................... 651
11.3.7 Learning Outcome 6: Use JavaScript Data types ................................................. 658
11.3.8 Learning Outcome 7: Use JavaScript Functions ................................................... 666
11.3.9 Learning Outcome 8: Use JavaScript Libraries .................................................... 671
CHAPTER 12: GRAPHIC DESIGN ...................................................................................... 676
12.1 Introduction ..................................................................................................................... 676
12.2 Performance Standard: .................................................................................................... 676
12.3 Learning Outcomes ......................................................................................................... 676
12.3.1 List of Learning Outcomes ...................................................................................... 676
12.3.2 Learning Outcome 1: Understand Graphic Design Fundamentals .......................... 677
12.3.3 Learning Outcome 2: Understand elements and principles of graphic design ........ 681
12.3.4 Learning Outcome 3: Apply typography techniques ............................................... 691
12.3.5 Learning Outcome 4: Create and edit images .......................................................... 705
12.3.6 Learning Outcome 5: Perform layout design ........................................................... 716
12.3.7 Learning Outcome 6: Print Design .......................................................................... 726

ix
LIST OF TABLES
Table 1: Basic Units of Learning .................................................................................................... 2
Table 2: Common Units of Learning .............................................................................................. 2
Table 3: Core Units of Learning ..................................................................................................... 2
Table 4: Primary and secondary memory ..................................................................................... 26
Table 5: Differences between Cache Memory and Virtual Memory ............................................ 29
Table 6: Examples of input devices .............................................................................................. 34
Table 7: Examples of common output devices ............................................................................. 35
Table 8: Number System Relationship ......................................................................................... 51
Table 9: ASCII .............................................................................................................................. 53
Table 10: System requirements for installing Windows 10 .......................................................... 82
Table 11: Comparison among Schedulers .................................................................................... 96
Table 12: Boolean Laws, Theorems and Expressions ................................................................ 186
Table 13: Commo derivative functions ....................................................................................... 205
Table 14: Common Derivative Rules.......................................................................................... 205
Table 15: The techniques/rules of integration............................................................................. 208
Table 16: Java Arithmetic Operators .......................................................................................... 248
Table 17: SQL comparison keywords ......................................................................................... 340

x
LIST OF FIGURES

Figure 1:Motherboard ..................................................................................................................... 6


Figure 2: Power supply ................................................................................................................... 7
Figure 3:Central Processing Unit (CPU) ........................................................................................ 7
Figure 4: RAM ................................................................................................................................ 8
Figure 5: Hard disk ....................................................................................................................... 8
Figure 6:Video Card........................................................................................................................ 9
Figure 7: Optical device drive ....................................................................................................... 10
Figure 8: Computer Internal components ..................................................................................... 10
Figure 9:CPU Registers ................................................................................................................ 15
Figure 10: Buses............................................................................................................................ 16
Figure 11:Fetch Execute Cycle ..................................................................................................... 17
Figure 12:Memory Organization in Computer Architecture ........................................................ 22
Figure 13:Cache Memory ............................................................................................................. 23
Figure 14:Secondary Memory ...................................................................................................... 26
Figure 15:Connection of I/O bus to I/O device ............................................................................. 37
Figure 16:PCI Slots ....................................................................................................................... 38
Figure 17:AGP Slot ....................................................................................................................... 39
Figure 18:Video/Graphics Card .................................................................................................... 39
Figure 19:Network Card ............................................................................................................... 40
Figure 20:USB Connectors ........................................................................................................... 40
Figure 21:Firewire Cable .............................................................................................................. 41
Figure 22:PS/2 Ports ..................................................................................................................... 41
Figure 23:Programmed I/O Mode Input Data Transfer ................................................................ 42
Figure 24:Interrupt- initiated I/O .................................................................................................. 43
Figure 25:Interrupt Processing ...................................................................................................... 45
Figure 26:DMA and Interrupt Breakpoints during an Instruction Cycle ...................................... 46
Figure 27:Typical DMA Block Diagram ...................................................................................... 47
Figure 28:Monolithic System Architecture................................................................................... 74
Figure 29:Layered architecture ..................................................................................................... 75
Figure 30:Virtual Architecture ...................................................................................................... 76
Figure 31:Layout of a process inside main memory ..................................................................... 90
Figure 32:Process States and Transition ....................................................................................... 92
Figure 33:Process Control Block (PCB) ....................................................................................... 93
Figure 34:Process Scheduling Queues .......................................................................................... 94
Figure 35:Context Switching ........................................................................................................ 97
Figure 36: Task Manager (Start window) ................................................................................... 102
Figure 37:Task Manager Details window ................................................................................... 103
Figure 38:Performance Monitor.................................................................................................. 107
Figure 39: Process Swapping in memory ................................................................................... 112
Figure 40: Memory fragmentation .............................................................................................. 114
Figure 41: Memory paging ......................................................................................................... 115

xi
Figure 42: Memory Address Translation .................................................................................... 115
Figure 43:Segmentation .............................................................................................................. 117
Figure 44:Virtual Memory .......................................................................................................... 118
Figure 45:Demand Paging .......................................................................................................... 119
Figure 46:Device Controllers ...................................................................................................... 127
Figure 47:Memory-mapped I/O .................................................................................................. 128
Figure 48: Windows Disk Manager ............................................................................................ 135
Figure 49:Disk Fragmentation .................................................................................................... 150
Figure 50: Windows Device Manager ........................................................................................ 153
Figure 51:Windows File explorer ............................................................................................... 163
Figure 52: Windows file sharing ................................................................................................. 164
Figure 53:Customising Files and directories using the File Explorer ......................................... 166
Figure 54:Configuring Local security policy .............................................................................. 168
Figure 55:Venn diagram ............................................................................................................. 194
Figure 56:Intersection of two sets ............................................................................................... 195
Figure 57:Complement of a set ................................................................................................... 195
Figure 58:Universal set ............................................................................................................... 196
Figure 59: MSAccess Database Sample ..................................................................................... 280
Figure 60:: MSAccess Table Sample ......................................................................................... 281
Figure 61: : MSAccess Table Records Sample ........................................................................... 281
Figure 62:: MSAccess Table Fields Sample. .............................................................................. 282
Figure 63:: MSSQL Server Interface .......................................................................................... 298
Figure 64: Database Data Modelling .......................................................................................... 310
Figure 65: Demonstrating Conceptual Data Model .................................................................... 311
Figure 66:Logical data Modelling............................................................................................... 312
Figure 67:Physical Data Modelling ............................................................................................ 313
Figure 68:Demonstrating an Entity ............................................................................................. 314
Figure 69:Entity Relationships.................................................................................................... 316
Figure 70:ER diagram with basic objects ................................................................................... 316
Figure 71: Elements in ER diagrams .......................................................................................... 317
Figure 72:Binary relationship ..................................................................................................... 318
Figure 73:Ternary relationship.................................................................................................... 318
Figure 74:Quaternary relationship .............................................................................................. 319
Figure 75:Recursive relationship ................................................................................................ 319
Figure 76:Entities associated through two distinct relationships with role names ..................... 320
Figure 77:ER diagram of Staff and Branch entities and their attributes ..................................... 320
Figure 78:Hashing in a database ................................................................................................. 373
Figure 79: Horizontal database fragmentation ............................................................................ 380
Figure 80:Vertical database fragmentation ................................................................................. 380
Figure 81:Hybrid database fragmentation.................................................................................. 380
Figure 82:Star Schema ................................................................................................................ 386
Figure 83:Snowflake Schema ..................................................................................................... 387
Figure 84:Fact Constellation Schema ......................................................................................... 387

xii
Figure 85:The Information Security Triad: Confidentiality, Integrity, Availability (CIA) ........ 396
Figure 86:SDLC waterfall ........................................................................................................... 401
Figure 87:The RAD methodology .............................................................................................. 402
Figure 88:Data Flow Diagram .................................................................................................... 404
Figure 89:Entity Modeling notations .......................................................................................... 407
Figure 90:Visual Studio IDE....................................................................................................... 419
Figure 91:VB.NET - Windows Forms ........................................................................................ 424
Figure 92:ADO.Net Object Model.............................................................................................. 434
Figure 93: VB.NET DataSet objects ........................................................................................... 436
Figure 94:Network components .................................................................................................. 451
Figure 95:LAN ............................................................................................................................ 453
Figure 96:MAN ........................................................................................................................... 454
Figure 97:WAN........................................................................................................................... 454
Figure 98:PAN ............................................................................................................................ 455
Figure 99:Star topology .............................................................................................................. 455
Figure 100:Ring topology ........................................................................................................... 456
Figure 101:Mesh topology .......................................................................................................... 458
Figure 102:Bus Topology ........................................................................................................... 459
Figure 103: Client Server Distributed Model ............................................................................. 464
Figure 104:Peer-to-peer Distributed Model ................................................................................ 465
Figure 105:Client Server Interaction........................................................................................... 478
Figure 106: Edge servers............................................................................................................. 480
Figure 107:Data Network showing devices ................................................................................ 493
Figure 108:Hub ........................................................................................................................... 495
Figure 109: How a switch works ................................................................................................ 497
Figure 110:How a bridge works.................................................................................................. 497
Figure 111:How a Wireless Access Point works ........................................................................ 498
Figure 112:Router ....................................................................................................................... 498
Figure 113: How a firewall works .............................................................................................. 499
Figure 114: OSI model layers ..................................................................................................... 506
Figure 115:Ping utility ................................................................................................................ 521
Figure 116:Tracert/traceroute utility ........................................................................................... 521
Figure 117:Netstat utility ............................................................................................................ 523
Figure 118:Pathping utility ......................................................................................................... 525
Figure 119:Mtr utility.................................................................................................................. 525
Figure 120: Networking Issues resolution .................................................................................. 525
Figure 121: AI related fields ....................................................................................................... 532
Figure 122:Intelligence agent...................................................................................................... 534
Figure 123: K-Nearest Neighbour-Image showing how similar data points typically exist close to
each other .................................................................................................................................... 575

xiii
LIST OF GRAPHS

Graph 1: Demonstrating y = mx+c ............................................................................................. 200


Graph 2: f(x) = |x| ........................................................................................................................ 201
Graph 3: y = x3 ............................................................................................................................ 201
Graph 4: Indefinite integral ......................................................................................................... 208
Graph 5: Definite integral ........................................................................................................... 208

xiv
CHAPTER 1: INTRODUCTION

1.1 Background Information


This learning guide has been developed in line with the functions of TVET CDACC as stipulated in
Article 45 (1a) of the Technical and Vocational Education and Training (TVET) Act No. 29 of 2013,
the Sessional Paper No. 2 of 2015 that embraces Competency Based Education and Training
(CBET) system. It is therefore, the sole intent of this document to provide guidelines for a
Competency-Based Computer Science Level 6.

This learning guide consists of interactive learning activities, content, self-assessment and relevant
and related references that enhance implementing of Computer Science level 6 qualification. It
enables the trainee to acquire the competencies that enable him/her to undertake the various
processes in Computer Science. The Guide further provides illustration, web links, case studies,
examples and resources on how to implement all the learning outcomes/elements described in the
Curriculum and occupational standards with a focus to a trainee level 6.

1.2 The Purpose of Developing the Trainee Guide


Computer Science level 6curriculum development process was initiated using the DACUM
methodology where jobs/occupations were identified. Further, job analysis charts and occupational
standards were generated in collaboration with the industry players under the guidance of TVET
CDACC (Curriculum Development Assessment and Certification Council). The result of the
process was a Computer Science level 6 curriculum. The curriculum was further broken down to
end up with units of learning. To effectively implement Computer Science level 6curriculum,
learning guides are required to provide training content and guide the learners and trainers on the
learning process aimed at imparting the relevant knowledge, requisite skills and the right attitude to
the industry. Learning guides are part of the training materials.

1.3 Layout of the Learning Guide


The learning guide is organized as per chapters. Chapter one presents the background information,
and purpose of developing the trainee guide. Each of the units of learning/unit of competency is
presented as a chapter on its own. Each chapter presents the introduction of the unit of learning/unit
of competency, performance standard and list of the learning outcome/elements in the occupational
standards.

• Learning Activities
For each learning outcome, the learning activities are presented covering the performance criteria
statements and trainee’s demonstration of knowledge in relation to the range in the occupational
standard and content in the curriculum.
● Information Sheet
The information sheet is section under each learning outcome that provides the subject matter in
relation to definition of key terms, method, processes/procedures/guidelines, content, illustrations
(photographs, pictures, video, charts, plans, digital content, and simulation) and case studies.

1
• Self-Assessment
Self-assessment is to the performance criteria, required knowledge, skills and the range as stated
in the occupational standards. The section further provides questions and assignments in which
trainees demonstrate that they have acquired the required competences and an opportunity to
reflect on what they have acquired. It is expected that the trainer keeps a record of their plans, their
progress and the problems they encountered which will go in trainee’s portfolio. A portfolio
assessment consists of a selection of evidence that meets the pre-defined requirements of
complexity, authenticity and reliability. The portfolio starts at the beginning of the training and
will be the evidence for the development and acquisition of the competence (summative and
formative) by the student. It is important to note that Portfolio assessment is highly emphasized in
the learning guide

Finally, the guide presents tools, equipment’s, supplies and materials for each learning outcome as
guided by the performance criteria in occupational standards and content in curriculum.
References, relevant links and addendums are provided for further reading. The units of
competency comprising this qualification include the following common and core unit of learning:

Common Units of Learning


Table 1: Basic Units of Learning

Unit of Learning Unit of Learning Title Duration in Credit


Code Hours Factor
IT/CU/CS/BC/01/6/A Communication skills 40 4
IT/CU/CS/BC/01/6/A Numeracy skills 60 6
IT/CU/CS/BC/01/6/A Digital literacy 60 6
IT/CU/CS/BC/01/6/A Entrepreneurship education 100 10
IT/CU/CS/BC/01/6/A Employability skills 80 8
IT/CU/CS/BC/01/6/A Environmental literacy 40 4
IT/CU/CS/BC/01/6/A Occupational safety and health 40 4
practices
Total 420 42
Common Units of Learning

Table 2: Common Units of Learning

Unit of Learning Unit of Learning Title Duration in Credit


Code Hours Factor
IT/CU/CS/CC/01/6/A Demonstrate Basic Electronic 170 17
Skills
Total 170 17

Core Units of Learning


Table 3: Core Units of Learning

2
Unit of Learning Code Unit of Learning Title Duration in Credit
Hours Factor
IT/CU/CS/CR/01/6/A Computer organization and 140 14
architecture
IT/CU/CS/CR/02/6/A Operating systems 130 13
IT/CU/CS/CR/03/6/A Mathematics for computer 140 14
science
IT/CU/CS/CR/04/6/A Fundamentals of programming 180 18
IT/CU/CS/CR/05/6/A Database management skills 160 16
IT/CU/CS/CR/06/6/A Information system 150 15
IT/CU/CS/CR/07/6/A Networking and distributed 210 21
systems
IT/CU/CS/CR/08/6/A Artificial intelligence 180 18
IT/CU/CS/CR/09/6/A Algorithms and data structures 170 17
IT/CU/CS/CR/10/6/A Web design skills 200 20
IT/CU/CS/CR/11/6/A Graphic design 170 17
Industrial attachment 480 48
Total 2310 231
Grand Total 2900 290

The total duration of the course is 2900 hours including 480 hours of industrial attachment.

3
CHAPTER 2: COMPUTER ORGANISATION AND ARCHITECTURE

2.1 Introduction
This unit covers the competencies required to understand Computer Organisation and
Architecture. It involves understanding principles of computer organisation and design,
understanding central processing unit functions, understanding computer memory organization,
understanding input-output functions and understanding computer arithmetic and logic.

2.2 Performance Standard


1. Identified hardware components of a computer
2. Prescribed CPU specifications according to a user’s needs
3. Verified CPU specifications for a given computer
4. Prescribed memory specifications according to a user’s needs

2.3 Learning Outcomes


2.3.1 List of Learning Outcomes
1. Understand principles of Computer Organization and Design
2. Understand Central Processing Unit functions
3. Understand computer memory organization
4. Understand Input-Output functions
5. Understand computer arithmetic and logic

4
2.3.2 Learning Outcome 1: Understand Principles of Computer Organization and Design
2.3.2.1 Learning Activities

Learning Outcome 1: Understand Principles of Computer Organisation and Design


Learning Activities Special Instructions

1.1. Computer organisation is defined Activities may be carried out in


1.2. Computer architecture is explained groups or as individual
1.3. Structure and function of computer components is
explained
1.4. Hardware components of a computer are identified

2.3.2.2 Information Sheet No 2/LO1: Understand Principles of Computer Organisation and


Design

Introduction
This learning outcome covers defining computer organisation, explaining and structure and
function of computer components and identifying hardware components.

Definition of key terms


Computer Organisation: refers to the level of abstraction above the digital logic level, but
below the operating system level.
Computer architecture: is a set of rules and methods that describe the functionality,
organization, and implementation of computer systems
Computer memory: is any physical device capable of storing information temporarily, like
RAM (random access memory), or permanently, like ROM (read-only memory).
Peripherals: Input or output devices that are connected to a computer. E.g. keyboard
Input peripherals: Allows user input, from the outside world to the computer. Example:
Keyboard, Mouse etc.
Output peripherals: Allows information output, from the computer to the outside world e.g.:
Printer, Monitor etc.
Input-Output peripherals: Allows both input (from outside world to computer) as well as,
output (from computer to the outside world). Example: Touch screen etc.
Computer Architecture: refers to those attributes of a system that have a direct impact on the
logical execution of a program.
Computer Organization: refers to the operational units and their interconnections that realize
the architectural specifications.
Structure: The way in which components relate to each other.
Function: the operation of individual components as part of the structure

Computer organization and architecture


Computer Organization is the realization of what is specified by the computer architecture. It
deals with how operational attributes are linked together to meet the requirements specified by
5
computer architecture. Some organizational attributes are hardware details, control signals,
peripherals.

Computer Architecture deals with giving operational attributes of the computer or Processor to
be specific. It deals with details like physical memory, ISA of the processor, the no of bits used to
represent the data types, Input Output mechanism and technique for addressing memories.
Examples are things that are transparent to the programmer:
● control signals
● interfaces between computer and peripherals
● the memory technology being used

Structure and function of computer components


Motherboard
As the given name, we can say this is either the start or endpoint of all components.
It is either the origin point of other parts of the computer or where every other component
connects to. In a way, it is a lot like what you would refer to your home country as: the
motherland.

It is basically a circuit board of a decent size, depending on the size of the computer we’re
dealing with. It facilitates the communication of the other components in the computer. There are
ports on the motherboard that face the outside of the computer, allowing you to plug in different
components into your computer and also to charge it.

Most motherboards also allow you to scale up by including slots that allow for expansion. You
could add in components like CPUs and RAMs, Video cards, and so on. You can also expand the
motherboard by adding more ports that allow you to connect even more auxiliary devices to your
computer. In other words, you have control over just what your computer’s capabilities are.
Apart from this, the motherboard plays other roles like storing some simple information when the
computer is off, such as the system time. That’s why your computer always tells you the correct
time, even when you turn it on after a long time
.

Figure 1:Motherboard

6
Power supply
As the name suggests, it powers all other components of the machine. It usually plugs into the
motherboard to power the other parts. The power supply connects to either an internal battery (on
a laptop) or a plug for an outlet (on a desktop).
They have different input voltage depending on the machine/computer specifications.

Figure 2: Power supply

Central Processing Unit (CPU)


Sometimes it's referred to as the computer’s brain. It is the workhorse of the machine. It performs
the calculations needed by a system, and can vary in speed. The work that a CPU does generates
heat, which is why your computer has a fan inside. A more powerful CPU is necessary for intense
computer work like editing high-definition video or programming complex software.

Figure 3:Central Processing Unit (CPU)

Random Access Memory (RAM)


RAM is a temporary memory. When you open an application in our computer, the computer will
place that application and all its data in the RAM. When you close the application, then space in
the RAM is freed. That is why your computer gets so slow when you have too many applications
open; your RAM is probably being used at capacity.

Since RAM is only temporary, it has a volatile nature. The minute you turn your computer off, all
of the memory that is stored in RAM is lost. That’s why you’re advised to keep saving the work

7
you do in applications as you go along to avoid losing all of it in case your computer suddenly
goes off.

The more RAM you have, the greater the number of programs that you can run simultaneously.

Figure 4: RAM

Hard disk /Solid State Disk


Remember that we said RAM is volatile due to its temporary nature, which means the computer
still needs a more permanent form of data storage. That’s why the hard drive or solid state drive
exists. Traditionally, the hard drive is a drum with several platters piled on it and spinning, and
the physical arm then writes data onto these platters. These disks are very slow because of the
mechanics through which data is stored, although latest hard drives, solid state drives, are much
faster.

Figure 5: Hard disk

Solid state drives have the same kind of memory as the one on your phone or flash drive, also
known as flash memory. They cost more but are also faster and more efficient than traditional
hard drives.

8
The data stored in the hard drive does not disappear when you switch your computer off. It will
be there when you switch the computer back on. You are, however, advised to keep it far away
from magnets as they could damage it and cause you to lose your information.

Video Card
The video card is a dedicated unit for handling image output to be displayed by the monitor. They
come with their own RAM, dedicated to this singular purpose. If your work involves highly
visual work at very high definitions, then you should get yourself a video card to take the load off
your RAM.

Sometimes, the computer may have integrated graphics, where some of the RAM is borrowed for
graphics processing. This happens frequently on laptops, because there is a need to save space.
Using integrated graphics is much less expensive using a graphics card, but is not sufficient for
intense graphics functions.

Figure 6:Video Card

Optical devices
These have become a lot less common today, with many machines doing away with them
altogether. An optical drive is used to read CDs and DVDs, which can be used to listen to music
or watch movies. They can also be used to install software, play games, or write new information
into a disk.
9
Figure 7: Optical device drive

In summary, here's the inside of a desktop computer with its parts labeled:

Figure 8: Computer Internal components

Conclusion
At the end of this learning outcome, the learner should be able to define computer organisation,
explain and structure and function of computer components and identify hardware components.

Further Reading
https://www.com/computer-organization-mcqs-basic-operational-concept/

2.3.2.3 Self-Assessment

Written Assessment
1. Which memory device is generally made of semiconductors?
a) RAM
10
b) Hard-disk
c) Floppy disk
d) CD ROM
2. The register which holds the address of the location to or from which data are to be transferred
is called
a) Instruction registers
b) Index register
c) Memory address
d) Memory data register
3. The device which is used to connect a peripheral to bus is called
a. Control Register
b. Interface
c. Communication Protocol
d. None of the above
4. Which of the following is not a form of memory?
a. Instruction cache
b. Instruction register
c. Instruction opcode
d. Both (a and b)
5. Which memory is difficult to interface with the processor?
a. Static memory
b. Dynamic memory
c. ROM
d. None of the Above
6. Which one of the following is an optical device?
a. DVD
b. Mouse
c. Desktop
d. Monitor.
7. What is computer hardware?
a. A medium for data communications
b. A physical device that is driven by data
c. A physical that is driven by software
d. All of the above
8. What does R in RAM stand for?
a. Re-write
b. Read
c. Readable
d. Random
9. DVD stands for?
a. Digital video data
b. Direct video
c. Digital versatile disk

11
d. Direct vertical disk
10. Which among the following storage devices is considered portable
a. Hard Disk
b. Magnetic Tape
c. Flash Drive
d. ROM
Oral Assessment
1. Differentiate functional and basic components.
2. Describe the functions of the RAM
3. What is a chipset?

Practical Assessment
You have been presented a set of hardware components. From the set, identify
• The hard disk
• Memory
• Power Supply
• An optical disk

2.3.2.4 Tools, Equipment, Supplies and Materials


● Computer
● Internet connectivity
● Stationery
● Instruction material

2.3.2.5 References

1. https://mrcet.com/downloads/digital_notes/IT/COMPUTER%20ORGANIZATION%20(
R17A0510).pdf
2. The "History of Computing" assembled Society by the IEEE Computer in 1996.

12
2.3.3 Learning Outcome 2: Understand Central Processing Unit functions
2.3.3.1 Learning Activities

Learning Outcome 2: Understand Central Processing Unit functions


Learning Activities Special Instructions

2.1 The Central Processing Unit is explained. Activities may be carried out in
2.2 CPU architecture is explained groups or as individual
2.3 Role of registers is explained
2.4 Instruction representation and execution is explained
2.5 CPU specifications are prescribed for a user
2.6 CPU specifications are verified for a given computer

2.3.3.2 Information Sheet No 2/LO2: Understand Central Processing Unit functions

Introduction
This learning outcome covers explaining the Central Processing Unit design, CPU architecture,
role of registers, instruction representation and execution, prescribing CPU specifications and
verifying CPU specifications for a given computer.

Definitions
❏ CPU is the electronic circuitry within a computer that carries out the instructions of a
computer program.
❏ Registers, a memory location within the actual processor that works at very fast speeds. It
stores instructions which are waiting to be decoded or executed.

CPU
It is s the electronic circuitry within a computer that carries out the instructions of a computer
program by performing the basic arithmetic, logical, control and input/output (I/O) operations
specified by the instructions.

Types of Processors
There are 2 different types of processors. These include:
● Complex instruction set computers (CISC)

13
● Reduced instruction set computers (RISC)
CISC
These processors can do complex operations, which can be carried out in just one instruction.
They have many different addressing modes and a wide range of instructions that can be used.
For example, a CISC processor might have a 'complicated' instruction designed into the hardware
called 'POWER'. This can take one number from a register, find the power of that number, held in
a different register, and then store the result in yet a third register. So, 2 to the power 4 would be
calculated as 16 and this would be stored in a third register. This would all be done using one
complex instruction, which might take about 3 or 4 CPU clock cycles to complete.

RISC
There are also CPUs that are known as RISC (pronounced ‘risk’), or Reduced Instruction Set
Computers. RISC processors such as ultra-SPARC and ALPHA use a much smaller, simpler set
of instructions than CISC processors and so to carry out any particular programming task may
take many ‘fetch decode execute’ cycles. RISC processors, however, are much more efficient at
processing huge blocks of data than CISC.

Standard CPU specification factors


There are four key factors about CPU architecture that affect its performance:
● Cores
○ A CPU can contain one or more processing units. Each unit is called a core. A core
contains an ALU, control unit and registers. It is common for computers to have
two (dual), four (quad) or even more cores. CPUs with multiple cores have more
power to run multiple programs at the same time.
● Clock speed
○ The clock speed - also known as clock rate - indicates how fast the CPU can run.
This is measured in megahertz (MHz) or gigahertz (GHz) and corresponds with
how many instruction cycles the CPU can deal with in a second.
● Cache size
○ Cache is a small amount of memory which is a part of the CPU - closer to the CPU
than RAM. It is used to temporarily hold instructions and data that the CPU is
likely to reuse.
● Processor type
○ Processor type can be either RISC or CISK. CPU ARCHITECTURE

CPU itself has the following three components.


● ALU(Arithmetic Logic Unit)
● Control Unit
● Memory Unit (Registers)

Control Unit
This unit controls the operations of all parts of the computer but does not carry out any actual data
processing operations.

14
Functions of this unit are −
● It is responsible for controlling the transfer of data and instructions among other units of a
computer.
● It manages and coordinates all the units of the computer.
● It obtains the instructions from the memory, interprets them, and directs the operation of the
computer.
● It communicates with Input/output devices for transfer of data or results from storage.
● It does not process or store data.

ALU (Arithmetic Logic Unit)


This unit consists of two subsections namely,
● Arithmetic Section
● Logic Section

Arithmetic Section
Function of the arithmetic section is to perform arithmetic operations like addition, subtraction,
multiplication, and division. All complex operations are done by making repetitive use of the
above operations.

Logic Section
Function of the logic section is to perform logic operations such as comparing, selecting, matching,
and merging of data.

Role of Registers
Processor register is a quickly accessible location available to a digital processor's central
processing unit.

The registers are an integral part of the CPU. They are a type of memory that can be accessed
very quickly compared to other types of memory. The pieces of information they hold are needed
by the CPU to run each program instruction during a 'fetch-decode-execute cycle' or can be used
to hold values that are generated as part of the ALU working on data. There are a number of very
special registers that do very specific jobs.

Figure 9:CPU Registers

15
Buses
A BUS is a data connection between two or more devices connected to the computer. For
example, a bus enables a computer processor to communicate with the memory or a video card to
with the memory.

These buses carry different types of signals. The same types of buses carry only one type of
signal. These buses help to increase the efficiency and accuracy of working.
A computer consists of many components such as motherboard, memory, input/output devices.
These devices work with the help of buses. PC motherboards have buses for expansion and
external devices, all computers have three basic buses.

Figure 10: Buses

We have three different types of buses. These are:


● DATA BUS
○ The control bus controls the traffic of data. It helps to send data, according to
the request of the user and PC.
● ADDRESS BUS
○ Data bus helps to connect the Microprocessor (CPU) and Memory (RAM).
● Control bus
○ The address bus carries the address of the location of memory.

Instruction representation and execution

Fetch Execute Cycle


This is the basic operation (instruction) cycle of a computer (also known as the fetch decode
execute cycle).

During the fetch execute cycle, the computer retrieves a program instruction from its memory. It
then establishes and carries out the actions that are required for that instruction.
16
The cycle of fetching, decoding, and executing an instruction is continually repeated by the CPU
whilst the computer is turned on.

Figure 11:Fetch Execute Cycle

1. Fetch
The first step the CPU carries out is to fetch some data and instructions (program) from main
memory then store them in its own internal temporary memory areas. These memory areas are
called 'registers'.

• For this to happen, the CPU makes use of a vital hardware path called the 'address bus'.
• The CPU places the address of the next item to be fetched on to the address bus.
• Data from this address then moves from main memory into the CPU by travelling along
another hardware path called the 'data bus'.

2. Decode
• The next step is for the CPU to make sense of the instruction it has just fetched. This
process is called 'decode'.
• The CPU is designed to understand a specific set of commands. These are called the
'instruction set' of the CPU. Each make of CPU has a different instruction set.
• The CPU decodes the instruction and prepares various areas within the chip in readiness
of the next step.

3. Execute
This is the part of the cycle when data processing actually takes place. The instruction is carried
out upon the data (executed). The result of this processing is stored in yet another register.
Once the execute stage is complete, the CPU sets itself up to begin another cycle once more.

Instruction Set
Instruction sets are instruction codes to perform some task. It is classified into five categories.

17
The instruction set, also called ISA (instruction set architecture) is part of a computer that pertains
to programming, which is basically machine language. The instruction set provides commands to
the processor, to tell it what it needs to do. The instruction set consists of addressing modes,
instructions, native data types, registers, memory architecture, interrupt, and exception handling,
and external I/O.

An example of an instruction set is the x86 instruction set, which is common to find on computers
today. Different computer processors can use almost the same instruction set while still having
very different internal design.

Both the Intel Pentium and AMD Athlon processors use nearly the same x86 instruction set. An
instruction set can be built into the hardware of the processor, or it can be emulated in software,
using an interpreter. The hardware design is more efficient and faster for running programs than
the emulated software version.

Examples of instruction set


• ADD - Add two numbers together.
• COMPARE - Compare numbers.
• IN - Input information from a device, e.g., keyboard.
• JUMP - Jump to designated RAM address.
• JUMP IF - Conditional statement that jumps to a designated RAM address.
• LOAD - Load information from RAM to the CPU.
• OUT - Output information to device, e.g., monitor.
• STORE - Store information to RAM.

Conclusion
At the end of this learning outcome, the learner should be able to explain the Central Processing
Unit design, the CPU architecture, the role of registers and instruction representation and
execution, prescribe CPU specifications and verify CPU specifications for a given computer.

Further Reading
1. https://www.tutorialspoint.com/computer_logical_organization/index.htm
2. https://www.javatpoint.com/computer-organization-and-architecture-tutorial

2.3.3.3 Self-Assessment

Written Assessment
1. A central processing unit (CPU) consists of two main parts:
a. Control unit and arithmetic logic unit.
b. Control unit and RAM.
c. Motherboard and arithmetic logic unit.
d. Control unit and motherboard.
18
2. The CPU control unit is responsible for
a. obtaining instructions
b. interpreting instructions
c. all logic functions
d. both A and B
3. DMA module can communicate with the CPU through
a. Interrupt
b. Cycle stealing
c. Branch instruction
d. None of the above
4. The ALU of a computer
a. Can perform addition, subtraction
b. Perform all types of arithmetic operation
c. Can perform AND OR and Multiplication
d. Contains number of counters
5. CPU gets the address of next instruction to be processed from
a. Instruction register
b. Memory address register
c. Index register
d. Program counter
6. Which one of the following devices is referred to as the ‘brain’ of the computer system?
a. CPU
b. CD-Rom
c. Mouse
d. Scanner
7. What is the other name for the Mother board
a. System processor
b. System platform
c. System unit
d. System board
8. What makes the computer to be an ‘electronic’ machine?
a. It works using electricity
b. It works without moving parts
c. It has a CPU
d. It has moving parts
9. What is the name given to devices designed to protect the computer from static electricity?
a. Anti-static devices
b. Power surge protectors
c. Personal equipment
d. Computer Hardware

Oral Assessment
Describe the role of buses.

19
Practical Assessment
Identify the following CPU specifications from your computer
• Clock Speed
• Manufacturer
• Generation

2.3.3.4 Tools, Equipment, Supplies and Materials


● Computer
● Internet connectivity
● Stationery
● Instruction material

2.3.3.5 References

1. https://www.geeksforgeeks.org/computer-organization-and-architecture-tutorials/
2. https://tutorialspoint.dev/computer-science/computer-organization-and-architecture

20
2.3.4 Learning Outcome 3: Understand Computer Memory Organization
2.3.4.1 Learning Activities

Learning Outcome 3: Understand Computer Memory Organization


Learning Activities Special Instructions

3.1 Memory organization is explained. Activities may be carried out in


3.2 Various storage technologies are explained. groups or as individual
3.3 Cache and Virtual memory are explained
3.4 Memory specifications are prescribed for a user
3.5 Memory specifications are verified for a given computer

2.3.4.2 Information Sheet 2/LO3: Understand Computer Memory Organization

Introduction

This learning outcome covers explaining memory organisation, various storage technologies,
cache and virtual memory, prescribing memory specifications for a user and verifying memory
specifications for a given computer.

Definition of key terms


• Memory
○ It is any physical device capable of storing information temporarily, or
permanently. Memory devices utilize integrated circuits and are used by operating
systems, software, and hardware.
○ is the storage space in the computer, where data is to be processed and instructions
required for processing are stored
• Memory unit
○ It is the collection of storage units or devices together.
• Memory hierarchy
○ It is an organizational structure in which memory units are ranked according to
levels of importance.
○ The computer memory hierarchy ranks components in terms of response times, with
processor registers at the top of the pyramid structure and tape backup at the
bottom.
• Virtual memory
○ Is a memory management capability of an operating system (OS) that uses
hardware and software to allow a computer to compensate for physical memory
shortages by temporarily transferring data from random access memory (RAM) to
disk storage

• Cached memory
21
○ a small-sized type of volatile computer memory that provides high-speed
data access to a processor and stores frequently used computer programs,
applications and data
• Volatile Memory: This loses its data, when power is switched off.
• Non-Volatile Memory: This is a permanent storage and does not lose any data when
power is switched off.

Memory Organization in Computer Architecture


Generally, memory/storage is classified into 2 categories:
● Volatile Memory: This loses its data, when power is switched off.
● Non-Volatile Memory: This is a permanent storage and does not lose any data when power
is switched off.

The total memory capacity of a computer can be visualized by hierarchy of components. The
memory hierarchy system consists of all storage devices contained in a computer system from the
slow Auxiliary Memory to fast Main Memory and to smaller Cache memory.

Figure 12:Memory Organization in Computer Architecture

Memory is primarily of three types −


● Cache Memory
● Primary Memory/Main Memory
● Secondary Memory

Cache Memory
Cache memory is a very high speed semiconductor memory which can speed up the CPU.
It acts as a buffer between the CPU and the main memory. It is used to hold those parts of data and
program which are most frequently used by the CPU. The parts of data and programs are
transferred from the disk to cache memory by the operating system, from where the CPU can
access them.

22
Figure 13:Cache Memory

Operations of the cache memory


■ Requests regarding the contents of memory location are done by CPU.
■ Check cache for this data
■ If present, get from cache (fast)
■ If not present, read required block from main memory to cache
■ Then deliver from cache to CPU

Cache deals with the tags so as to identify which block of main memory is present in each
cache slot

Advantages
The advantages of cache memory are as follows −
● 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
The disadvantages of cache memory are as follows −
● Cache memory has limited capacity.
● It is very expensive.

Primary Memory (Main Memory)


Primary memory holds only those data and instructions on which the computer is currently
working. It has a limited capacity and data is lost when power is switched off. (Volatile)
It is generally made up of semiconductor devices. These memories are not as fast as registers. The
data and instruction required to be processed resides in the main memory. It is divided into two
subcategories RAM and ROM.

23
RAM (Random Access Memory)
Random access memory (RAM) is the best known form of computer memory. RAM is
considered "random access" because you can access any memory cell directly if you know
the row and column that intersect at that cell.

Types of RAM:-
● Static RAM (SRAM)
● Dynamic RAM (DRAM)

Static RAM (SRAM)


❏ Stores data using the flip-flop state
❏ Retains value indefinitely, as long as it is kept powered.
❏ Mostly used to create cache memory of CPU.
❏ Faster and more expensive than DRAM.

Dynamic RAM (DRAM)


❏ Each cell stores a bit with a capacitor and transistor.
❏ Large storage capacity
❏ Needs to be refreshed frequently.
❏ Used to create main memory.
❏ Slower and cheaper than SRAM.

NVRAM:
❏ It is a category of Random Access Memory (RAM) that retains stored data even if
the power is switched off.
❏ NVRAM uses a tiny 24-pin dual inline package (DIP) integrated circuit chip, which
helps it to gain the power required to function from the CMOS battery on the
motherboard.
❏ NVRAM monitors several system parameters, such as Ethernet the MAC address,
serial number, date of manufacture, HOSTID, etc.
❏ NVRAM is a non-volatile memory type that provides the random access facility.

24
ROM: Read Only Memory
It is the memory from which we can only read but cannot write on it. This type of memory is non-
volatile.

The information is stored permanently in such memories during manufacture.


ROM stores such instructions that are required to start a computer. This operation is referred to as
bootstrap.

ROM chips are not only used in the computer but also in other electronic items like washing
machine and microwave oven.

There are five basic ROM types:


➢ ROM - Read Only Memory
➢ PROM - Programmable Read Only Memory
➢ EPROM - Erasable Programmable Read Only Memory
➢ EEPROM - Electrically Erasable Programmable Read Only Memory
➢ Flash EEPROM memory

Characteristics of Main Memory


● These are semiconductor memories.
● It is known as the main memory.
● Usually volatile memory.
● Data is lost in case power is switched off.
● It is the working memory of the computer.
● Faster than secondary memories.
● A computer cannot run without the primary memory.

Secondary Memory
This type of memory is also known as external memory or non-volatile.

It is slower than the main memory. These are used for storing data/information permanently. The
CPU does not directly access these memories; instead they are accessed via input-output routines.
The contents of secondary memories are first transferred to the main memory, and then the CPU
can access it. For example, disk, CD-ROM, DVD, etc.

25
Figure 14:Secondary Memory

Characteristics of Secondary Memory


● These are magnetic and optical memories.
● It is known as the backup memory.
● It is a non-volatile memory.
● Data is permanently stored even if power is switched off.
● It is used for storage of data in a computer.
● Computers may run without the secondary memory.
● Slower than primary memories.
Depending on whether secondary memory device is part of CPU or not, there are two types of
secondary memory – fixed and removable.

Table 4: Primary and secondary memory

Parameter Primary memory Secondary memory

Nature The primary memory is categorized The secondary memory is always a non-
as volatile & nonvolatile memories. volatile memory.

Alias These memories are also called Secondary memory is known as a Backup
internal memory. memory or Additional memory or Auxiliary
memory.

Access Data is directly accessed by the Data cannot be accessed directly by the
processing unit. processor. It is first copied from secondary
memory to primary memory. Only then
CPU can access it.

26
Formation It's a volatile memory meaning data It's a non-volatile memory so that that data
cannot be retained in case of power can be retained even after power failure.
failure.

Storage It holds data or information that is It stores a substantial amount of data and
currently being used by the information. Capacity is generally from
processing unit. Capacity is usually 200GB to terabytes.
in 16 to 32 GB

Accesses Primary memory can be accessed by Secondary memory is accessed by I/O


the data bus. channels.

Expense Primary memory is costlier than Secondary memory is cheaper than primary
secondary memory. memory.

Storage Devices

SSD Solid State Drive


It is a storage device that uses integrated circuit assemblies as memory to store data.
SSD are also known as solid-state disks although SSDs do not have physical disks.

Form-factors and protocols such as SATA and SAS of traditional hard disk drive (HDD) may be
used by SSD, greatly simplifying usage of SSDs in computers.

New form factors such as the M.2 form factor, and new I/O protocols such as NVM Express have
been developed to address specific requirements of the Flash memory technology used in SSDs.

Characteristics
● There are no moving mechanical components in SSD. This makes them different
from conventional electromechanical drives such as hard disk drives (HDDs) or
floppy disks, which contain movable read/write heads and spinning disks.
● SSDs are typically more resistant to physical shock.
● Run silently, have quicker access time and lower latency compared to
electromechanical devices.

27
Optical storage devices
This is an electronic data storage medium that can be written to and read from using a low-
powered laser beam.

Optical storage devices save data as patterns of dots that can be read using light. A laser beam is
the usual light source.

The data on the storage medium is read by bouncing the laser beam off the surface of the
medium.

Dots can be created using the laser beam (for media that is writable such as CD-Rs). The beam is
used in a high-power mode to actually mark the surface of the medium, making a dot. This
process is known as ‘burning’ data onto a disc.

28
Magnetic Storage Device
A magnetic disk is a storage device that uses a magnetization process to write, rewrite and access
data. It is covered with a magnetic coating and stores data in the form of tracks, spots and sectors.
Hard disks and zip disks are common examples of magnetic disks.

Virtual Memory

Virtual Memory is a technique to increase the main memory capacity. It uses data swap
technology and hard disk area is used as virtual memory.
It is a technique that is implemented using both hardware and software. It maps memory
addresses used by a program, called virtual addresses, into physical addresses in computer
memory.

Benefits of having Virtual Memory


1. Large programs can be written, as virtual space available is huge compared to physical
memory.
2. Less I/O required, leads to faster and easy swapping of processes.
3. More physical memory available, as programs are stored on virtual memory, so they occupy
very less space on actual physical memory.

Following are the important differences between Cache Memory and Virtual Memory.

Table 5: Differences between Cache Memory and Virtual Memory

Key Cache Memory Virtual Memory

1 Objective Cache memory increases Virtual memory increases the main


CPU access speed. memory capacity.

2 Memory Cache memory is a Virtual memory is a technique and


Unit memory unit and is very involves hard disk and is slower to
fast to access. access.

3 Management CPU and related Operating System manages virtual


hardware manages cache memory.
memory.

4 Size Cache memory is small Size of virtual memory is much larger


in size. than cache memory.

5 Operation Cache memory keeps Virtual memory keeps the programs


recently used data. which are not getting accommodated in
main memory.

29
Key RAM specifications to consider
• Physical Size
RAM modules vary in physical size based on the type of computer they're used for and the number
of pins on the module. Dual Inline Memory Modules (DIMMs) with 168 pins are 5.25 inches long.

DIMMs with fewer pins are typically smaller, with more pins meaning a physically larger module.
DIMMs are commonly used in desktop computers, whereas laptops typically use Small Outline
Dual Inline Memory Modules (SODIMMs). SODIMMs use the same technology but they're
physically smaller, allowing them to fit in laptops.
• Amount of memory
The amount is another important specification to remember. Your computer can only hold so much
RAM and while going over the specified limit won't harm your computer, your PC will only use as
much of it as it was designed to use. Amount is commonly measured in gigabytes (GB), though
older or low-end computers may measure maximum RAM in megabytes (MB). Some computers
have two slots to install memory, others have four and some have even more.

• Type of memory
The memory type is important because this is where the majority of RAM's compatibility issues lie.
Multiple variations of Double Data Rate (DDR) memory technology are used in various computers.

DDR2 is faster than DDR memory, while DDR3 memory is faster than both. If your computer
requires DDR3 memory, DDR2 memory won't work.
• Memory Speed
Memory speed is frequently denoted by "PC-" followed by a number that denotes the peak transfer
rate and bandwidth of that type of memory. For example, PC-2400's peak transfer rate is around
2,400 megabytes per second (MB/s). The peak transfer rate basically denotes the best performance
possible for that memory. "PC2" and "PC3" simply refer to DDR2 and DDR3 memory,
respectively.

The specifications may list the memory under a name known as the "friendly name," which looks
something like "DDR3-1066." In this case, 1066 represents the data transfer rate in millions per
second. All together, the memory specification may read something like "2 GB PC3-6400 DDR3
SODIMM."

Note: For hard disk storage, the capacity, usually in Gigabytes is the key factor to consider.

Conclusion
At the end of this learning outcome, the learner should be able to explain memory organisation,
various storage technologies, cache and virtual memory, prescribe memory specifications for a
user and verify memory specifications for a given computer.

Further Reading
30
1. https://www.tutorialspoint.com/computer_logical_organization/index.htm
2. https://www.javatpoint.com/computer-organization-and-architecture-tutorial

2.3.4.3 Self-Assessment

Written Assessment
1. Cache memory is used in a computer system to
a. Ensure fast booting
b. Replace static memory
c. Replace hard disk
d. Speed up memory access
2. Virtual memory of a computer system may be
a. Of unlimited size.
b. As big as maximum addressing capability of the computer system.
c. Of size equivalent to total capacity of secondary storage plus size of RAM.
d. None of the above
3. Which of the following is not an advantage of Dynamic RAMs
a. High density
b. Low cost
c. High speed
d. No need of memory refresh
4. In the memory hierarchy the fastest memory
a. SRAM
b. Cache
c. Registers
d. DRAM
5. Cache memory is implemented using
a. Dynamic RAM
b. Static RAM
c. PROM
d. EPROM
6. Which one of the following is the odd one out?
a. Primary memory
b. Secondary memory
c. Tertiary memory
d. Cached memory
7. What makes SSD different from conventional electromechanical drives
a. they contain movable read/write heads
b. they have spinning disks
c. They do not have moving mechanical components
d. They are hard Disks
31
8. Which of the following Disks are more resistant to physical shock
a. SSDs
b. Floppy Disks
c. HDDs
d. None of the above
9. The following are all types of secondary memory except.
a. Hard drive
b. RAM
c. SSD
d. Flash
10. Which one of the following statements is true?
a. Primary memory is the main memory of the computer system.
b. Rom is part of the secondary memory
c. Secondary memory is not useful at all to the computer
d. Secondary memory is also called internal memory.
Oral Assessment
1. Describe DRAM
2. Differentiate between cache and virtual memory

Practical Assessment
1. Verify the memory and hard disk specifications of the computer provided.
2. Prescribe memory specifications for a user intending to install and use video and
graphics production software.

2.3.4.4 Tools, Equipment, Supplies and Materials


● Computer
● Internet connectivity
● Stationery
● Instruction material

2.3.4.5 References

1. https://www.geeksforgeeks.org/computer-organization-and-architecture-tutorials/
2. https://tutorialspoint.dev/computer-science/computer-organization-and-architecture
3. https://www.techwalla.com/articles/random-access-memory-specifications

32
2.3.5 Learning Outcome 4: Understand Input-Output functions
2.3.5.1 Learning Activities

Learning Outcome 4: Understand Input-Output functions


Learning Activities Special Instructions

4.1 Peripherals devices are explained Activities may be carried out in


4.2 Input-output processing is explained groups or as individual
4.3 Bus interface is explained
4.4 Modes of data transfer are explained
4.5 Input-output device specifications are prescribed
for a user
4.6 Input-output device specifications are verified
for a given computer

2.3.5.2 Information Sheet 2/LO4: Understand Input-Output functions

Introduction

This learning outcome covers the explaining categorizing the peripheral devices, explain
Input/output (I/O) processing, explain bus interface role in I/O and different modes of data
transfer. It also involves prescribing I/O specifications for a user and verifying I/O specifications
for a given computer.

Definition of key terms


• Peripheral: A peripheral device is an internal or external device that connects to a computer
but does not contribute to the computer's primary function, such as computing. It helps end
users access and use the functionalities of a computer.

• Bus: A bus is a subsystem that transfers data between computer components inside a
computer or between computers

Overview of peripheral devices


A peripheral is a device that can be attached to the computer processor. Peripheral devices can be
external, such as a mouse, keyboard, printer, monitor or scanner. Peripheral devices can also be
internal, such as a CD-ROM drive, DVD-R drive or modem.

Categories
We have different categories. These include;
● Input
● Output
● storage

33
Input Devices
A device that feeds data into a computer processor is called an input device.
Input can take a variety of forms, from commands you enter from the keyboard to data from
another computer or device.

Examples of input devices


Table 6: Examples of input devices

Device Description Image

Keyboard A keyboard resembles a


typewriter which contains a
set of keys used to input data
and control commands to the
computer. The most
common keyboard has 101
keys with 12 functions keys.

Mouse A mouse is a drawing and


pointing device. A mouse
has one or more buttons on
the top. When a user rolls a
mouse across the flat
surface, the cursor moves on
the screen in the direction of
mouse movement.

Touch screen This is the easiest way to


enter data using the finger
touch. A touch screen allows
the users to select an option
by pressing a specific part of
the screen.

Touchpad Many laptop computers use a


touchpad in front of the
keyboard. We move our
finger on the pad to move
the cursor on the screen.

34
Trackballs It is pointing devices and
contains a ball which can be
rotated in any direction. The
user spins the ball in a
different direction to move
the cursor on the screen.

Joystick It is a pointing device which


is used to move the cursor
position on the screen. A
joystick is a stick which has
a spherical ball at its lower
ends as well as its upper
ends. Joysticks are
commonly used in playing
the game.

Output Devices
A device that shows data from a computer processor is an output device.
Output can also appear in a variety of forms - text, video, graphics, and so on.

Examples of common output devices


Table 7: Examples of common output devices

Device Description Image

Monitor The most common output device


used with computers is the
monitor, which displays video
images and text.

Projectors Projectors are output


devices used mainly by
companies, schools, and
churches to show
information to a large body
of people at the same time

35
Plotters Plotters are generally used
with engineering
applications, for generating
a hard copy of a digitally
created design. In addition,
Plotters are also often used
by graphic artists,
architects, constructions
engineers etc

speakers/headphones These are hardware devices that


transform the signal from the
computer's sound card into audio

Backing Storage Devices


Backing storage is a device which holds and retains data.

These devices allow the user to save data in a more permanent way than RAM so that data is not
lost and may be used at a later time.

Peripheral specifications
These specifications should match the user’s needs. If the user needs to save/store data, they will
need storage, a device categorized as storage will be ideal.

The user specification may entail a very long list of devices depending on the special purpose at
hand.

I/O Processing
I/O processor is a processor separate from the CPU designed to handle only input/output
processes for a device or the computer.

The I/O processor is capable of performing actions without interruption or intervention from the
CPU. The CPU only needs to initiate the I/O processor by telling it what activity to perform.
Once the necessary actions are performed, the I/O processor then provides the results to the CPU.

Doing these actions allow the I/O processor to act as a bus to the CPU, carrying out activities by
directly interacting with memory and other devices in the computer. A more advanced I/O

36
processor may also have memory built into it, allowing it to perform actions and activities more
quickly.

Bus Interface unit (BIU)


BIU takes care of all data and addresses transfers on the buses for the EU (Execution Unit) like
sending addresses, fetching instructions from the memory, reading data from the ports and the
memory as well as writing data to the ports and the memory. EU has no direct connection with
System Buses so this is possible with the BIU. EU and BIU are connected with the Internal Bus.

BUS: is a communication system that transfers data between components inside a computer, or
between computers

Interface: is a hardware circuitry between the microcomputer and the I/O devices. It provides all
the input/output transfer.
They connect/interface the computer and the peripherals.

Figure 15:Connection of I/O bus to I/O device

Types of buses
Each bus defines its set of connectors to physically plug devices, cards or cables together. There are
two types of buses: internal and external. Internal buses are connections to various internal
components. External buses are connections to various external components. There are different kinds
of slots that internal and external devices can connect to.

Internal

Types of Slots
There are many different kinds of internal buses, but only a handful of popular ones. Different
computers come with different kinds and number of slots. It is important to know what kind and
number of slots you have on your computer before you go out and by a card that matches up to a
slot you don’t have.

PCI
PCI (Peripheral Component Interconnect) is common in modern PCs. This kind of bus is being
succeeded by PCI Express. Typical PCI cards used in PCs include: network cards, sound cards,
37
modems, extra ports such as USB or serial, TV tuner cards and disk controllers. Video cards have
outgrown the capabilities of PCI because of their higher bandwidth requirements.

Figure 16:PCI Slots

PCI Express
PCI Express was introduced by Intel in 2004. It was designed to replace the general-purpose PCI
expansion bus and the AGP graphics card interface.

PCI express is not a bus but instead a point-to-point connection of serial links called lanes. PCI
Express cards have faster bandwidth then PCI cards which make them more ideal for high-end
video cards.

PCMCIA
PCMCIA (also referred to as PC Card) is the type of bus used for laptop computers. The name
PCMCIA comes from the group who developed the standard: Personal Computer Memory Card
International Association.

PCMCIA was originally designed for computer memory expansion, but the existence of a usable
general standard for notebook peripherals led to many kinds of devices being made available in this
form. Typical devices include network cards, modems, and hard disks.

AGP
AGP (Accelerated Graphics Port) is a high-speed point-to-point channel for attaching a graphics
card to a computer’s motherboard, primarily to assist in the acceleration of 3D computer graphics.
AGP has been replaced over the past couple years by PCI Express. AGP cards and motherboards
are still available to buy, but they are becoming less common.

38
Figure 17:AGP Slot

Types of Cards

Video Card
A video card (also known as graphics card) is an expansion card whose function is to generate and
output images to a display. Some video cards offer added functions, such as video capture, TV
tuner adapter, ability to connect multiple monitors, and others. Most video cards all share similar
components.

They include a graphics processing unit (GPU) which is a dedicated microprocessor optimized for
3D graphics rendering. It also includes video BIOS that contains the basic program that governs
the video card’s operations and provides the instructions that allow the computer and software to
interface with the card. If the video card is integrated in the motherboard, it may use the computer
RAM memory. If not, it will have its own video memory called Video RAM.

This kind of memory can range from 128MB to 2GB. A video card also has a RAMDAC (Random
Access Memory Digital-to-Analog Converter) which takes responsibility for turning the digital
signals produced by the computer processor into an analog signal which can be understood by the
computer display. Lastly, they all have outputs such as an HD-15 connector (standard monitor
cable), DVI connector, S-Video, composite video or component video.

Figure 18:Video/Graphics Card

Sound Card
A sound card is an expansion card that facilitates the input and output of audio signals to/from a
computer under control of computer programs. Typical uses for sound cards include providing the
audio component for multimedia applications such as music composition, editing video or audio,
presentation/education, and entertainment. Many computers have sound capabilities built in, while
others require additional expansion cards to provide for audio capability.

Network Card
A network card is an expansion card that allows computers to communicate over a computer
network. It allows users to connect to each other either by using cables or wirelessly. Although
other network technologies exist, Ethernet has achieved near-ubiquity for a while now. Every
Ethernet network card has a unique 48-bit serial number called a MAC address, which is stored in
ROM carried on the card.
39
Figure 19:Network Card

External

Types of Connections

USB
USB (Universal Serial Bus) is a serial bus standard to interface devices. USB was designed to allow
many peripherals to be connected using a single standardized interface socket and to improve the
plug-and-play capabilities by allowing devices to be connected and disconnected without rebooting
the computer.

Other convenient features include providing power to low-consumption devices without the need
for an external power supply and allowing many devices to be used without requiring manufacturer
specific, individual device drivers to be installed. USB is by far the dominating bus for connecting
external devices to your computer.

Figure 20:USB Connectors

Firewire
Firewire (technically known as IEEE 1394 and also known as i.LINK for Sony) is a serial bus
interface standard for high-speed communications and isochronous real-time data transfer,
frequently used in a personal computer. Firewire has replaced Parallel ports in many applications.
It has been adopted as the High Definition Audio-Video Network Alliance (HANA) standard
connection interface for A/V (audio/visual) component communication and control. Almost all
modern digital camcorders have included this connection.

40
Figure 21:Firewire Cable

PS/2
The PS/2 connector is used for connecting some keyboards and mice to a PC compatible computer
system. The keyboard and mouse interfaces are electrically similar with the main difference being
that open collector outputs are required on both ends of the keyboard interface to allow bidirectional
communication. If a PS/2 mouse is connected to a PS/2 keyboard port, the mouse may not be
recognized by the computer depending on configuration.

Figure 22:PS/2 Ports

Modes of data transfer:


There are different modes of data transfer. We are going to have a look at the following:
➔ Programmed I/O
➔ Interrupt initiated I/O
➔ Direct memory access(DMA)

Programmed I/O
Programmable I/O is one of the I/O techniques other than the interrupt-driven I/O and direct
memory access (DMA). The programmed I/O is the simplest type of I/O technique for the
exchanges of data or any types of communication between the processor and the external
devices. With programmed I/O, data is exchanged between the processor and the I/O module.
The processor executes a program that gives it direct control of the I/O operation, including
sensing device status, sending a read or write command, and transferring the data. When the
processor issues a command to the I/O module, it must wait until the I/O operation is complete.
If the processor is faster than the I/O module, this is wasteful of processor time.

The overall operation of the programmed I/O can be summarized as follows:


• The processor is executing a program and encounters an instruction relating to I/O
operation.
• The processor then executes that instruction by issuing a command to the appropriate I/O
module.
41
• The I/O module will perform the requested action based on the I/O command issued by
the processor (READ/WRITE) and set the appropriate bits in the I/O status register.
• The processor will periodically check the status of the I/O module until it finds that the
operation is complete.

I/O Commands
Figure 23:Programmed I/O Mode Input Data Transfer

To execute an I/O-related instruction, the processor issues an address, specifying the particular
I/O module and external device, and an I/O command. There are four types of I/O commands that
an I/O module may receive when it is addressed by a processor:
● Control: Used to activate a peripheral and tell it what to do. For example, a magnetic-tape
unit may be instructed to rewind or to move forward one record. These commands are
tailored to the particular type of peripheral device.
● Test: Used to test various status conditions associated with an I/O module and its
peripherals. The processor will want to know that the peripheral of interest is powered on
and available for use. It will also want to know if the most recent I/O operation is completed
and if any errors occurred.
● Read: Causes the I/O module to obtain an item of data from the peripheral and place it in an
internal buffer. The processor can then obtain the data item by requesting that the I/O
module place it on the data bus.
● Write: Causes the I/O module to take an item of data (byte or word) from the data bus and
subsequently transmit that data item to the peripheral.

Advantages and disadvantages of programmed I/O


42

Advantages - simple to implement

- very little hardware support

Disadvantages - busy waiting

- ties up CPU for long period with no useful work

Interrupt- initiated I/O


Interrupt I/O is a way of controlling input/output activity whereby a peripheral or terminal that
needs to make or receive a data transfer sends a signal. This will cause a program interrupt to be
set at a time appropriate to the priority level of the I/O interrupt.

Relative to the total interrupt system, the processors enter an interrupt service routine. The
function of the routine will depend upon the system of interrupt levels and priorities that is
implemented in the processor. The interrupt technique requires more complex hardware and
software, but makes far more efficient use of the computer’s time and capacities.

Figure 24:Interrupt- initiated I/O

43
For input, the device interrupts the CPU when new data has arrived and is ready to be retrieved by the
system processor. The actual actions to perform depend on whether the device uses I/O ports or memory
mapping.

For output, the device delivers an interrupt either when it is ready to accept new data or to acknowledge
a successful data transfer. Memory-mapped and DMA-capable devices usually generate interrupts to tell
the system they are done with the buffer.

Here the CPU works on its given tasks continuously. When an input is available, such as when someone
types a key on the keyboard, then the CPU is interrupted from its work to take care of the input data.
The CPU can work continuously on a task without checking the input devices, allowing the devices
themselves to interrupt it as necessary.

Basic Operations of Interrupt

1. CPU issues read command.


2. I/O module gets data from peripheral whilst CPU does other work.
3. I/O module interrupts CPU.
4. CPU requests data.
5. I/O module transfers data.

Interrupt Processing

44
Figure 25:Interrupt Processing

1. A device driver initiates an I/O request on behalf of a process.


2. The device driver signals the I/O controller for the proper device, which initiates the requested
I/O.
3. The device signals the I/O controller that is ready to retrieve input, the output is complete or that
an error has been generated.
4. The CPU receives the interrupt signal on the interrupt-request line and transfer control over the
interrupt handler routine.
5. The interrupt handler determines the cause of the interrupt, performs the necessary processing
and executes a “return from” interrupt instruction.
6. The CPU returns to the execution state prior to the interrupt being signaled.
7. The CPU continues processing until the cycle begins again.

Direct Memory Access (DMA)


Different from Programmed I/O and Interrupt-Driven I/O, Direct Memory Access is a technique
for transferring data within main memory and external device without passing it through the
CPU.

It is a way to improve processor activity and I/O transfer rate by taking-over the job of
transferring data from the processor, and letting the processor do other tasks.

This technique overcomes the drawbacks of other two I/O techniques which are the time
consuming process when issuing command for data transfer and tie-up the processor in data

45
transfer while the data processing is neglected. It is more efficient to use the DMA method when
large volumes of data has to be transferred.

For DMA to be implemented, the processor has to share its’ system bus with the DMA module.
Therefore, the DMA module must use the bus only when the processor does not need it, or it
must force the processor to suspend operation temporarily. The latter technique is more common
to be used and it is referred to as cycle stealing.

Figure 26:DMA and Interrupt Breakpoints during an Instruction Cycle

Basic Operation of DMA


When the processor wishes to read or send a block of data, it issues a command to the DMA
module by sending some information to the module. The information includes:
● Read or write command, sending through read and write control lines.
● Number of words to be read or written, communicated on the data lines and stored in the
data count register.
● Starting location in memory to read from or write to, communicated on data lines and stored
in the address register.
● Address of the I/O device involved, communicated on the data lines.

46
Figure 27:Typical DMA Block Diagram

After the information is sent, the processor continues with other work. The DMA module then
transfers the entire block of data directly to or from memory without going through the processor.
When the transfer is complete, the DMA module sends an interrupt signal to the processor to
inform that it has finished using the system bus.

Advantages & Disadvantages of DMA

Advantages Allows a peripheral device to read from/write to memory


without going through the CPU

Allows for faster processing since the processor can be working


on something else while the peripheral can be populating
memory

Disadvantages Requires a DMA controller to carry out the operation, which


increases the cost of the system

Cache coherence problems

Key I/O Specifications for a computer


• Keyboard – Layout, Language and ease of use.
• Mouse – Type (Wireless, wired)
• Monitor – Resolution, Size
• Printer – Speed (Pages per minutes), Colour or non-colour, resolution (dpi), type (impact
vs. non impact)
47
Further Reading
1. https://www.tutorialspoint.com/computer_fundamentals/computer_input_devices.htm
2. https://www.tutorialspoint.com/computer_fundamentals/computer_hardware.htm

Conclusion
At the end of this learning outcome, the learner should be able to explain and categorizing the
peripheral devices, explain Input/output (I/O) processing, explain the bus interface role in I/O and
different modes of data transfer. The learner should also able to prescribe I/O specifications for a
user and verify I/O specifications for a given computer.

6.3.5.3 Self-Assessment

Written Assessment
1. What is a peripheral device?
2. What is the purpose of the Bus Interface Unit?
3. Which specifications are important for a monitor?
4. How is an interrupt processed?
5. What type of devices are computer speakers or headphones?
a. Input
b. Input/output
c. Software
d. Output
Oral Assessment
1. Distinguish between programmed and Interrupt driven I/O.
2. How does DMA process I/O requests?
Practical Assessment
1. Verify the various I/O ports in your PC.
2. Confirm the specifications of the I/O devices attached to your computer.

6.3.5.4 Tools, Equipment, Supplies and Materials


● Computer
● Internet connectivity
● Stationery
● Instruction material
6.3.5.5 References

1. http://openbookproject.net/courses/intro2ict/hardware/peripherals.html
2. https://www.tutorialspoint.com/computer_fundamentals/computer_components.htm

48
2.3.6 Learning Outcome 5: Understand computer arithmetic and logic
2.3.6.1 Learning Activities
Learning Outcome 5: Understand computer arithmetic and logic
Learning Activities Special Instructions

5.1 Number systems are explained Activities may be carried out in


5.2 Integer and Floating point representations are groups or as individual
demonstrated according to IEEE standard
5.3 Integer and Floating point arithmetic is explained
5.4 Logic operators are explained
5.5 Logic operations are explained
5.6 Methods of representing logic operations are
demonstrated

2.3.6.2 Information Sheet No. 2/LO5: Understand computer arithmetic and logic

Introduction
This learning outcome involves explaining number systems, demonstrating Integer and floating
point representations according to IEEE standard, explaining integer and floating point
arithmetic, logic operators and logic operations and demonstrating methods of representing logic
operations.

The Number System


The technique to represent and work with numbers is called the number system.
We have different types of numbering systems. They include:
● Decimal number system
● The binary number system
● octal number system
● hexadecimal number system

Decimal Number System


Decimal number system is a base 10 number system having 10 digits from 0 to 9. This means that
any numerical quantity can be represented using these 10 digits. Decimal number system is also a
positional value system. This means that the value of digits will depend on its position. Let us
take an example to understand this.

Say we have three numbers – 734, 971 and 207. The value of 7 in all three numbers is different−
● In 734, value of 7 is 7 hundreds or 700 or 7 × 100 or 7 × 102
● In 971, value of 7 is 7 tens or 70 or 7 × 10 or 7 × 101
● In 207, value 0f 7 is 7 units or 7 or 7 × 1 or 7 × 100

The weightage of each position can be represented as follows –


49
Decimal Number System

Binary Number System


The easiest way to vary instructions through electric signals is the two-state system – on and off.
On is represented as 1 and off as 0, though 0 is not actually a no signal but signal at a lower
voltage.
The number system having just these two digits – 0 and 1 – is called binary number system.
Each binary digit is also called a bit. Binary number system is also a positional value system,
where each digit has a value expressed in powers of 2, as displayed here.

Binary Number System

In any binary number, the rightmost digit is called least significant bit (LSB) and leftmost digit is
called most significant bit (MSB).

Least significant bit (LSB) and most significant bit (MSB)

And the decimal equivalent of this number is the sum of the product of each digit with its
positional value.
110102 = 1×24 + 1×23 + 0×22 + 1×21 + 0×20
= 16 + 8 + 0 + 2 + 0
= 2610

Computer memory is measured in terms of how many bits it can store. Here is a chart for memory
capacity conversion.
● 1 byte (B) = 8 bits
● 1 Kilobytes (KB) = 1024 bytes
● 1 Megabyte (MB) = 1024 KB
● 1 Gigabyte (GB) = 1024 MB
● 1 Terabyte (TB) = 1024 GB
● 1 Exabyte (EB) = 1024 PB
● 1 Zettabyte = 1024 EB
● 1 Yottabyte (YB) = 1024 ZB

50
Octal Number System
Octal number system has eight digits – 0, 1, 2, 3, 4, 5, 6 and 7.
Octal number system is also a positional value system with where each digit has its value
expressed in powers of 8, as shown here –

Octal Number System

Decimal equivalent of any octal number is the sum of the product of each digit with its positional
value.
7268 = 7×82 + 2×81 + 6×80
= 448 + 16 + 6
= 47010

Hexadecimal Number System


Octal number system has 16 symbols – 0 to 9 and A to F where A is equal to 10, B is equal to 11
and so on till F. Hexadecimal number system is also a positional value system with where each
digit has its value expressed in powers of 16, as shown here –

Hexadecimal Number System

Decimal equivalent of any hexadecimal number is the sum of the product of each digit with its
positional value.
27FB16 = 2×163 + 7×162 + 15×161 + 10×160
= 8192 + 1792 + 240 +10
= 1023410

Number System Relationship


The following table depicts the relationship between decimal, binary, octal and hexadecimal
number systems.

Table 8: Number System Relationship

HEXADECIMAL DECIMAL OCTAL BINARY

0 0 0 0000

51
1 1 1 0001

2 2 2 0010

3 3 3 0011

A 10 12 1010

B 11 13 1011

C 12 14 1100

ASCII
Besides numerical data, computers must be able to handle alphabets, punctuation marks,
mathematical operators, special symbols, etc. that form the complete character set of English
language. The complete set of characters or symbols are called alphanumeric codes. The complete
alphanumeric code typically includes –

● 26 upper case letters


● 26 lower case letters
● 10 digits
● 7 punctuation marks
● 20 to 40 special characters

Now a computer understands only numeric values, whatever the number system used. So all
characters must have a numeric equivalent called the alphanumeric code. The most widely used
alphanumeric code is American Standard Code for Information Interchange (ASCII). ASCII is a 7-
bit code that has 128 (27) possible codes.

52
Table 9: ASCII

Unicode
Unicode is an international coding system designed to be used with different language scripts.
Each character or symbol is assigned a unique numeric value, largely within the framework of
ASCII. Earlier, each script had its own encoding system, which could conflict with each other.

In contrast, this is what Unicode officially aims to do − Unicode provides a unique number for
every character, no matter what the platform, no matter what the program, no matter what the
language.

Number Systems Conversions

Decimal to Binary
Decimal numbers can be converted to binary by repeated division of the number by 2 while
recording the remainder.

Example:
53
The remainders are to be read from bottom to top to obtain the binary equivalent.
4310 = 1010112

Decimal to Octal
Decimal numbers can be converted to octal by repeated division of the number by 8 while
recording the remainder.

Example:

Reading the remainders from bottom to top,


47310 = 7318

Decimal to Hexadecimal
Decimal numbers can be converted to octal by repeated division of the number by 16 while
recording the remainder.

Example:

Reading the remainders from bottom to top we get,


42310 = 1A716

Binary to Octal and Vice Versa


To convert a binary number to octal number, these steps are followed −
● Starting from the least significant bit, make groups of three bits.

54
● If there are one or two bits less in making the groups, 0s can be added after the most
significant bit
● Convert each group into its equivalent octal number

Example:

101100101012 = 26258

To convert an octal number to binary, each octal digit is converted to its 3-bit binary equivalent
according to this table.

Example:
Octal Digit 0 1 2 3 4 5 6 7

Binary Equivalent 00 00 01 01 10 10 11 11
0 1 0 1 0 1 0 1
546738 = 1011001101110112

Binary to Hexadecimal
To convert a binary number to hexadecimal number, these steps are followed −
● Starting from the least significant bit, make groups of four bits.
● If there is one or two bits less in making the groups, 0s can be added after the most
significant bit.
● Convert each group into its equivalent octal number.

Example:

55
101101101012 = DB516
To convert an octal number to binary, each octal digit is converted to its 3-bit binary equivalent.

IEEE-based Integer and Floating point representations

Integers
An integer is a whole number (not a fraction) that can be positive, negative, or zero. Therefore,
the numbers 10, 0, -25, and 5,148 are all integers.

Integers are a commonly used data type in computer programming. For example, whenever a
number is being incremented, such as within a "for loop" or "while loop," an integer is used.
Integers are also used to determine an item's location within an array.

When two integers are added, subtracted, or multiplied, the result is also an integer. However,
when one integer is divided into another, the result may be an integer or a fraction. For example,
6 divided by 3 equals 2, which is an integer, but 6 divided by 4 equals 1.5, which contains a
fraction. Decimal numbers may either be rounded or truncated to produce an integer result.

Floating Point numbers


As the name implies, floating point numbers are numbers that contain floating decimal points.
For example, the numbers 5.5, 0.001, and -2,345.6789 are floating point numbers.

Computers recognize real numbers that contain fractions as floating point numbers. When a
calculation includes a floating point number, it is called a "floating point calculation." Older
computers used to have a separate floating point unit (FPU) that handled these calculations, but
now the FPU is typically built into the computer's CPU.

Floating point arithmetic


Arithmetic operations on floating point numbers consist of addition, subtraction, multiplication
and division the operations are done with algorithms similar to those used on sign magnitude
integers (because of the similarity of representation) -- example, only add numbers of the same
sign. If the numbers are of the opposite sign, you must do subtraction.

Addition
Example on decimal value given in scientific notation:
3.25 x 10 ** 3
+ 2.63 x 10 ** -1
-----------------
First step: Align decimal points

Second step: add

56
3.25 x 10 ** 3
+ 0.000263 x 10 ** 3
--------------------
3.250263 x 10 ** 3
(Presumes use of infinite precision, without regard for accuracy)

Third step: normalize the result

Example on fl pt. value given in binary:


.25 = 0 01111101 00000000000000000000000
100 = 0 10000101 10010000000000000000000

To add these fl. pt. representations,


Step 1: Align radix points
Shifting the mantissa LEFT by 1 bit DECREASES THE EXPONENT by 1
Shifting the mantissa RIGHT by 1 bit INCREASES THE EXPONENT by 1

We want to shift the mantissa right, because the bits that fall off the end should come from the
least significant end of the mantissa
-> Choose to shift the .25, since we want to increase its exponent.
-> Shift by 10000101
-01111101
---------
00001000 (8) places.

0 01111101 00000000000000000000000 (original value)


0 01111110 10000000000000000000000 (shifted 1 place)
(note that hidden bit is shifted into msb of mantissa)
0 01111111 01000000000000000000000 (shifted 2 places)
0 10000000 00100000000000000000000 (shifted 3 places)
0 10000001 00010000000000000000000 (shifted 4 places)
0 10000010 00001000000000000000000 (shifted 5 places)
0 10000011 00000100000000000000000 (shifted 6 places)
0 10000100 00000010000000000000000 (shifted 7 places)
0 10000101 00000001000000000000000 (shifted 8 places)

Step 2: Add (don't forget the hidden bit for the 100)
0 10000101 1.10010000000000000000000 (100)
+ 0 10000101 0.00000001000000000000000 (.25)
---------------------------------------
0 10000101 1.10010001000000000000000
Step 3: normalize the result (get the "hidden bit" to be a 1)
It already is for this example.

57
The result is
0 10000101 10010001000000000000000

Subtraction
Like addition as far as alignment of radix points then the algorithm for subtraction of sign mag.
numbers takes over.

Before subtracting, compare magnitudes (don't forget the hidden bit!)


Change sign bit if order of operands is changed. Don't forget to normalize numbers afterward.

Multiplication
Example on decimal values given in scientific notation:
3.0 x 10 ** 1
+ 0.5 x 10 ** 2
-----------------

Algorithm: multiply mantissa, add exponents


3.0 x 10 ** 1
+ 0.5 x 10 ** 2
-----------------
1.50 x 10 ** 3

Example in binary: Use a mantissa that is only 4 bits so that you don’t take long doing the
multiplication part.
0 10000100 0100
x 1 00111100 1100
-----------------
Mantissa multiplication: 1.0100
(don't forget hidden bit) x 1.1100
------
00000
00000
10100
10100
10100
---------
1000110000
becomes 10.00110000

Add exponents: Always add true exponents (otherwise the bias gets added in twice)

58
Biased:
10000100
+ 00111100
----------
10000100 01111111 (switch the order of the subtraction,
- 01111111 - 00111100 so that we can get a negative value)
---------- ----------
00000101 01000011
true exp true exp
is 5. is -67
Add true exponents 5 + (-67) is -62.
Re-bias exponent: -62 + 127 is 65.

Unsigned representation for 65 is 01000001.

Put the result back together (and add sign bit).


1 01000001 10.00110000

Normalize the result:


(Moving the radix point one place to the left increases the exponent by 1.)

1 01000001 10.00110000
becomes
1 01000010 1.000110000

This is the value stored (not the hidden bit!):


1 01000010 000110000

Division
• Similar to multiplication.
• True division: do unsigned division on the mantissas (don't forget the hidden bit)
• Subtract TRUE exponents

The IEEE standard is very specific about how all this is done. Unfortunately, the hardware to
do all this is very slow.

Some comparisons of approximate times:


2's complement integer add 1 time unit
fl. pt add 4 time units
fl. pt multiply 6 time units
fl. pt. divide 13 time units

59
There is a faster way to do division. It’s called division by reciprocal approximation. It takes
about the same time as a fl. pt. multiply. Unfortunately, the results are not always the same as
with true division.

Division by reciprocal approximation:


Instead of doing a / b, they do a x 1/b.
Figure out a reciprocal for b, and then use the fl. pt.

Example of a result that isn't the same as with true division.


True division: 3/3 = 1 (exactly)
Reciprocal approx: 1/3 = .33333333

3 x .33333333 = .99999999, not 1

It is not always possible to get a perfectly accurate reciprocal.

Rounding
Arithmetic operations on fl. pt. values compute results that cannot be represented in the given
amount of precision. So, we must round results.

There are MANY ways of rounding. They each have "correct" uses, and exist for different
reasons. The goal in a computation is to have the computer round such that the end result is as
"correct" as possible.

Methods of rounding:
Round toward 0 -- also called truncation.
Figure out how many bits (digits) are available. Take that many bits (digits) for the result and
throw away the rest. This has the effect of making the value represented closer to 0.

Example:
.7783 If 3 decimal places available, .778
If 2 decimal places available, .77

Round toward + infinity -- regardless of the value, round towards +infinity.

Example:
1.23 If 2 decimal places, 1.3
-2.86 if 2 decimal places, -2.8

Round toward - infinity -- regardless of the value, round towards -infinity.

Example:
1.23 If 2 decimal places, 1.2

60
-2.86 if 2 decimal places, -2.9

In binary -- rounding to 2 digits after radix point


Round toward + infinity --
1.1101
|
1.11 | 10.00
------
1.001
|
1.00 | 1.01
-----

Round toward - infinity --

1.1101
|
1.11 | 10.00
------
1.001
|
1.00 | 1.01
-----
Round toward zero (TRUNCATE) --
1.1101
|
1.11 | 10.00
------
1.001
|
1.00 | 1.01
-----
-1.1101
|
-10.00 | -1.11
------
-1.001
|
-1.01 | -1.00
-----
Round toward nearest --

ODD CASE:

61
If there is anything other than 1000 to the right of the number of digits to be kept, it is
rounded in IEEE standard such that the least significant bit (to be kept) is a zero.

1.1111
|
1.11 | 10.00
------
1.1101
|
1.11 | 10.00
------
1.001 (ODD CASE)
|
1.00 | 1.01
-----
-1.1101 (1/4 of the way between)
|
-10.00 | -1.11
------
-1.001 (ODD CASE)
|
-1.01 | -1.00
-----
Integer Representation and Arithmetic

Integer Representation
● Bit-- Binary Digit
○ 1 byte = 8 bits
○ 1 word = 2 bytes
● Integer takes up two bytes; can be signed or unsigned.

Unsigned Integers
● Can represent whole numbers from 0 to 65,535
○ (0 to 216 - 1).
● In binary, this is from
○ 02to 11111111111111112
● Internally, binary representation of decimal value is 16 bits.

Signed Integers
● Need to reserve one bit for the sign.
● Three ways:
○ Sign-Magnitude
○ 1's Complement

62
○ 2's Complement
Sign-Magnitude
● Uses the most significant bit of the word to represent the sign.
○ 0 - Positive
○ 1 - Negative.
● Rest of the number is encoded in magnitude part
37 = 00000000 00100101
-37 = 10000000 00100101
6712 = 00011010 00111000
-6712 = 10011010 00111000
● Can represent numbers from -32,767 to 32,767.
○ -215+1 .. 215-1
● But, two representations for zero:
0 = 00000000 00000000
● -0 = 10000000 00000000 Arithmetic can be cumbersome.

1's Complement
● Negative numbers are stored as bitwise complement of corresponding positive numbers.
● Leftmost bit of the positive number is 0. That of the negative number is 1.
196 = 00000000 11000100
-196 = 11111111 00111011
● Can represent numbers from -32,767 to 32,767.
○ -215+1 .. 215-1
● Arithmetic is easier than sign-magnitude.
● But, still have two representations for zero:
0 = 00000000 00000000
-0 = 11111111 11111111

2's Complement
● Modern Method: Positive number represented in same way as other two methods
● Negative number obtained by taking 1's Complement of positive number and adding 1.
6713 = 00011000 00011101
1's Comp = 11100111 11100010
2's Comp = 11100111 11100011
● Word integers can represent numbers from -32,768 to 32,767.
○ -215 .. 215-1
● Byte integers can represent numbers from -128 to 127.
○ -27 .. 27-1
● One version of zero:
00000000 00000000

Conversion of Byte Integer to Word


● Sign Extension

63
● Copy sign bit of the byte into all the bits of the upper byte of the word.
37 = 00100101 -> 00000000 00100101
● -37 = 11011011 -> 11111111 11011011 cbw
○ converts the signed byte in AL to a word in AX

Conversion of Word Integer to Byte


● Remove the upper byte of the word. Retain only the lower byte.
● Meaningful only if the original number can be represented by a byte.

Integer Arithmetic (1's Comp and 2's Comp)


● Addition: Simply add the two binary representations.
● Subtraction: Find negative of one number, add to the second.

Addition in 1's Comp


● Add binary representations of the two numbers.
● If there is a carry, add it back in on the right side.
51 00110011
+ (-37) + 11011010
----------
1 00001101
+1
----------
14 00001110

Addition in 2's Comp


● Add binary representations of the two numbers.
● Disregard the carry.
51 00110011
+ (-37) + 11011011
----------
14 1 00001110

Subtraction in 2's Comp


Overflow
● If two numbers have different signs, their sum will never overflow.
● If they have the same sign, they might overflow.
● Overflow has occurred if sign of result is different than sign of addends.

Logic operators and Logic Operations


A logical operator is a special symbol or word that connects two or more phrases of information.

We have a range of the logic operators which include OR, AND, NOT, NOR, XOR and XNOR.

64
OR
The OR logic operation returns True if either its inputs are True. If all inputs are false, the output
is also false. In computer programming, the OR operation is usually written as || (two vertical
bars). In Boolean algebra, the OR value of two inputs A and B can be written as A+B.

Note Do not mistake the OR operation for arithmetic addition, even though they both use the "+"
symbol. They are distinct operations.

Below is the circuit diagram of an OR logic gate.

OR logic gate

AND
The AND logic operation returns True only if either of its inputs are True. If either of the inputs
is False the output is also false. In computer programming, the AND operation is usually written
as && (two ampersands). In Boolean algebra, the AND operation of two inputs A and B can be
written as AB.

Below is the circuit diagram of an AND logic gate.

OR logic gate

NOT
The NOT logic operation returns True if its input is False, and False if its input is True. In
computer programming, the NOT operation is usually written as ! (an exclamation mark). In
Boolean algebra, the NOT value of an input A can be written as A̅ (A with an overscore).

Below is the circuit diagram of a NOT logic gate.

NOT logic gate

NOR
65
The NOR logic operation “stands for NOT OR” returns true if either of its inputs are false, and
false if either of its inputs are true. In Boolean algebra, the NOR value of two inputs A and B can
be written as (A+B with an overscore). NOR has the distinction of being one of two
"universal" logic gates, because any other logic operation can be created using only NOR gates.
(The other universal logic gate is NAND.)

Below is the circuit diagram of a NOR logic gate.

NOR logic gate

XOR
The XOR logic operation (which stands for "Exclusive OR" returns true if either of its inputs
differ, and false if they are all the same. In other words, if its inputs are a combination of true and
false, the output of XOR is true. If its inputs are all true or all false, the output of XOR is false. In
Boolean algebra, the XOR value of two inputs A and B can be written as A⊕B (the XOR
symbol, resembles a plus sign inside a circle).

Below is the XOR operation circuit diagram.

Exclusive OR gate

XNOR
The XNOR logic operation (which stands for "Exclusive NOT OR" returns true if either of its
inputs are the same, and false if either of them differ. In other words, if its inputs are a
combination of true and false, the output of XNOR is false. If its inputs are all true or all false,
the output of XNOR is true. In Boolean algebra, the XNOR value of two inputs A and B can be
written as (the XOR symbol ⊕, resembles a plus sign inside a circle with a line over
everything).

Below is the XNOR operation circuit diagram.

Exclusive NOT OR gate

66
Karnaugh map
A Karnaugh map provides a pictorial method of grouping together expressions with common
factors and therefore eliminating unwanted variables. The Karnaugh map can also be described as
a special arrangement of a truth table.

The diagram below illustrates the correspondence between the Karnaugh map and the truth table
for the general case of a two variable problem.

The values inside the squares are copied from the output column of the truth table, therefore there
is one square in the map for every row in the truth table. Around the edge of the Karnaugh map
are the values of the two input variable. A is along the top and B is down the left hand side. The
diagram below explains this:

The values around the edge of the map can be thought of as coordinates. So as an example, the
square on the top right hand corner of the map in the above diagram has coordinates A=1 and
B=0. This square corresponds to the row in the truth table where A=1 and B=0 and F=1. Note
that the value in the F column represents a particular function to which the Karnaugh map
corresponds.

Conclusion
At the end of this learning outcome, the learner should be able to explain number systems,
demonstrate integer and floating point representations according to IEEE standard explain

67
integer and floating point arithmetic, logic operators and logic operations and demonstrate
methods of representing logic operations.

Further Reading
1. https://www.tutorialspoint.com/fixed-point-and-floating-point-number-representations
2. https://www.tutorialspoint.com/computer_logical_organization/boolean_algebra.htm

2.3.6.3 Self-Assessment

Written Assessment
1. Which of the following is not a logical operator?
a. And
b. OR
c. Else
d. NOT

2. Boolean operator which combines search terms so that each search result contains all of
terms, is
a. and operator
b. not operator
c. or operator
d. nor operator
3. The sign magnitude representation of -1 is?
a. 1001
b. 1000
c. 0001
d. 1110
4. The ALU gives the output of the operations and the output is stored in the?
a. Memory devices
b. Registers
c. Flags
d. Output Unit
5. The bitwise complement of 0 is?
a. 00000001
b. 11111111
c. 11111110
d. 10000000

Oral Assessment
1. Describe the logical operators
2. Describe with illustrations how to convert Decimal to binary
68
Practical Assessment
Research on the application areas of logic operations in computer science.

2.3.6.4 Tools, Equipment, Supplies and Materials


● Computer
● Internet connectivity
● Calculator
● Stationery
● Instruction material

2.3.2.5 References

1. http://mathworld.wolfram.com/KarnaughMap.html
2. https://www.tutorialspoint.com/computer_logical_organization/boolean_algebra.htm
3. https://www.tutorialspoint.com/digital_circuits/digital_circuits_boolean_algebra.htm

69
CHAPTER 3: OPERATING SYSTEMS

3.1 Introduction
This unit covers the competencies required to understand operating systems. It involves
understanding fundamentals of operating systems, understanding process management,
understanding memory management, understanding input-output management and understanding
file management.

3.2 Performance Standard


1. Installed Windows Operating system
2. Demonstrated process management using the task manager
3. Demonstrated resource allocation using the performance monitor tool
4. Demonstrated disk storage management operations
5. Demonstrated device management using the Device Manager
6. Demonstrated file and directory operations
7. Configured local policy security settings.

3.3. Learning Outcomes


3.3.1. List of learning outcomes
1. Understand fundamentals of operating systems
2. Understand Process Management
3. Understand Memory Management
4. Understand Input and Output Management
5. Understand File Management and local policy settings

70
3.3.2 Learning Outcome No 1: Understand fundamentals of operating systems
3.3.2.1 Learning Activities
Learning Outcome 1: Understand fundamentals of operating systems
Learning Activities Special Instructions

1.1 Computer Software is explained ● Activities may be carried out in


1.2 Operating system is explained groups or as individual
1.3 Structures of operating systems are described.
1.4 Types of operating systems are explained.
1.5 Installation requirements for Windows are outlined
1.6 Installation of Windows is demonstrated

3.3.2.2 Information sheet No 3/LO1: Understand fundamentals of operating systems

Introduction
This learning outcome covers explaining computer software, explaining operating system, describing
structures of operating systems, explaining types of operating systems, outlining installation
requirements for Windows and demonstrating installation of Windows.

Definition of key terms


Software: A set of programs, which is designed to perform a well-defined function. There are two
types of software; System Software and Application Software.

Computer program: A sequence of instructions written to solve a particular problem.

System Software: It is a collection of programs designed to operate, control, and extend the
processing capabilities of the computer itself. It is usually developed by the computer
manufacturers. Some examples of system software are Operating System, Compilers, Interpreter,
Assemblers, etc.

Application Software: This is software designed to satisfy a particular need of a particular


environment. Application software may consist of a single program, such as Adobe Reader or
consist of a collection of programs, often called a software package, which work together to
accomplish a task, such as a Microsoft Office.

Operating system concepts

Definition
An operating System is a collection of system programs that together control the operations of a
computer system.

The operating system acts as an intermediary between a user of a computer and the computer
hardware.
71
Some examples of operating systems are UNIX, Microsoft Disk Operating System (MS-DOS),
Microsoft Windows (Simply called Windows), OS/2 and MacOS.

An operating system has two parts


(i) The Kernel: This is the active part of an operating system which is running at all times.
It consist of programs which can interact with the hardware. Examples are device drivers
and system files.
(ii) The Shell - It is also called the command interpreter. It is a set of programs used to
interact with the application programs. It is responsible for execution of instructions
given to the operating system.

The goals of an operating system in a computer system include:


• Executing user programs and make solving user problems easier.
• Making the computer system convenient to use.
• Using the computer hardware in an efficient manner.

Functions of Operating Systems


i) Process Management
• A process is a program in execution. A process needs certain resources, including CPU
time, memory, files, and I/O devices, to accomplish its task.
• The operating system is responsible for the following activities in connection with process
management.
o Process creation and deletion.
o Process suspension and resumption.
o Provision of mechanisms for process synchronization and process
communication

ii) Main-Memory
• Memory is a large array of words or bytes, each with its own address. It is a repository of
quickly accessible data shared by the CPU and I/O devices.
• The operating system is responsible for the following activities in connection with
memory management:
o Keep track of which parts of memory are currently being used and by whom.
o Decide which processes to load when memory space becomes available.
o Allocate and de-allocate memory space as needed.

iii) File Management


• A file is a collection of related information defined by its creator. Commonly, files
represent programs (both source and object forms) and data.
• The operating system is responsible for the following activities in connections with file
management:
o File creation and deletion.
72
o Directory creation and deletion.
o Support of mechanisms for manipulating files and directories.
o Mapping files onto secondary storage.
o File backup on stable (non-volatile) storage media.

iv) The Input/Output (I/O) System Management


The I/O system consists of:
• A buffer-caching system
• A general device-driver interface
• Drivers for specific hardware devices

v) Secondary-Storage Management
Since main memory (primary storage) is volatile and too small to accommodate all data and
programs permanently, the computer system must provide secondary storage to back up main
memory.

Most modern computer systems use disks as the principle on-line storage medium, for both
programs and data.

The operating system is responsible for the following activities in connection with disk
management:
• Free space management
• Storage allocation
• Disk scheduling

vi) Networking (Distributed Systems)


• A distributed system is a collection of processors that do not share memory or a clock.
Each processor has its own local memory.
• The processors in the system are connected through a communication network.
• Communication takes place using a protocol.
• A distributed system provides user access to various system resources.
• Access to a shared resource allows:
o Computation speed-up
o Increased data availability
o Enhanced reliability

vii) Protection System


• Protection refers to a mechanism for controlling access by programs, processes, or users
to both system and user resources.
• The protection mechanism must:
o Distinguish between authorized and unauthorized usage.
o Specify the controls to be imposed.
o Provide a means of enforcement.
73
viii) Command-Interpreter System
• Many commands are given to the operating system by control statements which deal with
all the above functions.
• The program that reads and interprets control statements is called variously; command-
line interpreter and shell (in UNIX)
• The function of the command-interpreter system is to get and execute the next command
statement.

Structures of operating systems


Operating systems services are built using various architectures, including:
• Monolithic system architecture
• Layered architecture
• Virtual Structure
• Client Server model

Monolithic System Architecture


In this architecture, the entire operating system works in the kernel space. This increases the size
of the kernel as well as the operating system. The kernel provides various services such as memory
management, file management and process scheduling.

The diagram below demonstrates the architecture of a monolithic system

Figure 28:Monolithic System Architecture

Layered architecture

74
In this architecture, the operating system is split into various layers and each of the layers have
different functionalities.

Each of the layers in the operating system can only interact with the layers that are above and below
it. The lowest layer handles the hardware and the uppermost layer deals with the user applications.

Figure 29:Layered architecture

Layer Function
Hardware interacts with the system hardware and
coordinates with all the peripheral devices used
such as printer, mouse, keyboard, scanner etc
CPU Scheduling Deals with scheduling the processes for the
CPU. When the processes enter the system,
they are put into the job queue. The processes
that are ready to execute in the main memory
are kept in the ready queue.
Memory Management Moving of processes from disk to primary
memory for execution and back again.
Process Management Assigns the processor to a process at a time .
This is known as process scheduling.
I/O Buffer Handles the buffers for the I/O devices and
makes sure that they work correctly.
User Programs Deals with the many user programs and
applications that run in an operating system
such as word processors, games, browsers etc.

Layering has several advantages:


• All the layers can be defined separately and interact with each other as required.
• It is easier to create, maintain and update the system if it is done in the form of layers.
Change in one layer specification does not affect the rest of the layers.

75
Virtual Architecture
The concept of a virtual machine is to provide an interface that looks like independent hardware,
to multiple different operating systems running simultaneously on the same physical hardware.
Each operating system believes that it has access to and control over its own CPU, RAM, I/O
devices, hard drives, etc.

One use for this system is for the development and testing of software that must run on multiple
platforms and/or operating systems. A key difficulty involves the sharing of hard drives, which
are generally partitioned into separate smaller virtual disks for each operating system.

Figure 30:Virtual Architecture

Client Server Architecture


Client Server communication involves two components, namely a client and a server. They are
usually multiple clients in communication with a single server. The clients send requests to the
server and the server responds to the client requests.

Types of Operating Systems

Batch Processing Operating Systems


This type of operating systems accepts more than one job and these jobs are batched/ grouped
together according to their similar requirements. This is done by computer operator. Whenever
the computer becomes available, the batched jobs are sent for execution and gradually the output
is sent back to the user.
76
Multiprogramming Operating Systems
This type of operating system is used to execute more than one job simultaneously by a single
processor. It increases CPU utilisation by organizing jobs so that the CPU always has one job to
execute.

The concept of multiprogramming works as follows:


• All the jobs that enter the system are stored in the job pool (in disc). The operating system
loads a set of jobs from the job pool into main memory and begins to execute.
• During execution, the job may have to wait for some task, such as an I/O operation, to
complete. In a multiprogramming system, the operating system simply switches to
another job and executes.
• When that job needs to wait, the CPU is switched to another job, and so on.
• When the first job finishes waiting and it gets the CPU back.
• As long as at least one job needs to execute, the CPU is never idle.

Time-Sharing/multitasking Operating Systems


A time sharing (or multitasking) operating system is a logical extension of multiprogramming. It
provides extra facilities such as:
• Faster switching between multiple jobs to make processing faster.
• Allows multiple users to share computer system simultaneously.
• The users can interact with each job while it is running.
• These systems use a concept of virtual memory for effective utilisation of memory space.
Hence, in this operating system, no jobs are discarded. Each one is executed using the
virtual memory concept.
• Examples of timesharing systems: MULTICS and UNIX

Multiprocessor Operating Systems


Such operating systems have more than one processor in close communication that sharing the
computer bus, the clock and sometimes memory and peripheral devices. It executes multiple jobs
at same time and makes the processing faster.

Multiprocessor systems have three main advantages:


• Increased throughput: By increasing the number of processors, the system performs more
work in less time.
• Economy of scale: Multiprocessor systems can save more money than multiple single-
processor systems, because they can share peripherals, mass storage, and power supplies.
• Increased reliability: If one processor fails to done its task, then each of the remaining
processors must pick up a share of the work of the failed processor. The failure of one
processor will not halt the system, only slow it down.

Distributed Operating Systems

77
In a distributed system, the different machines are connected in a network and each machine has
its own processor and own local memory.

In this systems, operating systems on all the machines work together to manage the collective
network resource.

The advantages of distributed systems include:


• Resources sharing
• Computation speed up – load sharing
• Reliability – Each machine has processing capability and can take over the work of
another machine that fails.

Desktop Systems/Personal Computer Systems


The PC operating system is designed for maximizing user convenience and responsiveness. This
system is neither multi-user nor multitasking. These systems include PCs running Microsoft
Windows and the Apple Macintosh.

Real-Time Operating Systems (RTOS)


A real-time operating system (RTOS) is a multitasking operating system intended for applications
with fixed deadlines (real-time computing). Such applications include some small embedded
systems, industrial robots, spacecraft, industrial control and some large-scale computing systems.

Installing Windows Operating System


Different versions of Windows operating system have different installation requirements.

Definition of key terms

BIOS - (basic input/output system) is the program (firmware) a personal computer's


microprocessor uses to get the computer system started after you turn it on. It also manages data
flow between the computer's operating system and attached devices such as the hard disk, video
adapter, keyboard, mouse and printer.

A disk image is a copy of the entire contents of a storage device, such as a hard drive, DVD, or
CD. The disk image represents the content exactly as it is on the original storage device,
including both data and structure information.

Firmware is a specific class of computer software that provides the low-level control for the
device's specific hardware. Firmware can either provide a standardized operating environment for
the device's more complex software (allowing more hardware-independence), or, for less
complex devices, act as the device's complete operating system, performing all control,
monitoring and data manipulation functions.

78
Typical examples of devices containing firmware are embedded systems, consumer appliances,
computers, computer peripherals, and others. Almost all electronic devices beyond the simplest
contain some firmware.

Original equipment manufacturer (OEM) is an original equipment manufacturer (OEM) is a


company whose goods are used as components in the products of another company, which then
sells the finished item to users.

Disk partitioning or disk slicing is the creation of one or more regions on secondary storage, so
that each region can be managed separately. These regions are called partitions.

PrebooteXecution Environment (PXE) is an industry standard client/server interface that allows


networked computers that are not yet loaded with an operating system to be configured and
booted remotely by an administrator.

Types of installations

Attended installation
On Windows systems, this is the most common form of installation. An installation process
usually needs a user who attends it to make choices, such as accepting or declining an end-user
license agreement (EULA), specifying preferences such as the installation location, supplying
passwords or assisting in product activation. In graphical environments, installers that offer a
wizard-based interface are common.

Attended installers may ask users to help mitigate the errors. For instance, if the disk in which the
computer program is being installed was full, the installer may ask the user to specify another
target path or clear enough space in the disk.

Silent installation
Installation that does not display messages or windows during its progress. "Silent installation" is
not the same as "unattended installation" (see below): All silent installations are unattended but
not all unattended installations are silent. The reason behind a silent installation may be
convenience or subterfuge. Malware is almost always installed silently

Unattended installation
Installation that is performed without user interaction during its progress or with no user present
at all. One of the reasons to use this approach is to automate the installation of a large number of
systems. An unattended installation either does not require the user to supply anything or has
received all necessary input prior to the start of installation. Such input may be in the form of
command line switches or an answer file, a file that contains all the necessary parameters.

Headless installation

79
Installation performed without using a computer monitor connected. In attended forms of
headless installation, another machine connects to the target machine (for instance, via a local
area network) and takes over the display output. Since a headless installation does not need a user
at the location of the target computer, unattended headless installers may be used to install a
program on multiple machines at the same time.

Scheduled or automated installation


An installation process that runs on a preset time or when a predefined condition transpires, as
opposed to an installation process that starts explicitly on a user's command. For instance, a
system administrator willing to install a later version of a computer program that is being used
can schedule that installation to occur when that program is not running.

An operating system may automatically install a device driver for a device that the user connects.
(Plug and play.) Malware may also be installed automatically. For example, the infamous
Conficker was installed when the user plugged an infected device to their computer.

Network installation
Network installation, shortened netinstall, is an installation of a program from a shared network
resource that may be done by installing a minimal system before proceeding to download further
packages over the network. This may simply be a copy of the original media but software
publishers which offer site licenses for institutional customers may provide a version intended for
installation over a network.

Methods of windows desktop operating system installation

i) Clean Installation
We can perform a clean installation on a new computer or in those cases where there is no
upgrade path between the current operating system and the new one. A new PC requires, of
course a clean installation. You can also do a clean install when the current operating system
installation has corrupted files or does not work properly.

Advantages of a clean installation


• A clean installation is an opportunity to start fresh from scratch without any unwanted
software and trial software that might have come pre-installed with your system.
• You will also regain control over your applications, as you can now install only the
applications you need, and you'll also start with a brand new and clean Windows Registry.
• Chances of running into errors and other issues will significantly be reduced. If your PC had
any software or hardware issues, doing a clean installation likely resolves any problems.

Disadvantages of clean installation


• Starting from scratch also takes longer than doing a plain in-place upgrade because you will
need to reinstall and reconfigure any software you previously had.
• It also requires that you have the applications installation files and products keys.
80
• If the Windows setup cannot recognize different hardware in your computer, you will have
to manually find and install all the necessary drivers, which is not sometimes an easy task
• Besides deleting all your applications and settings, performing a clean installation of
Windows will delete all your files. Therefore make sure you backup all your data before
using the upgrade path.

ii) Upgrade Installation


Sometimes, it is also possible to perform an upgrade. When you perform an upgrade, OS
configuration settings, installed programs and data are preserved. With this installation you have
nothing to worry about, because you will not lose any personal data. You will just replace the old
operating system files with the new, upgraded files.

Advantages of upgrading
• You do not have reformat your hard drive. The new operating system will simply replace
your previous installation, and you will be able to keep all of your files and programs.
• This process takes the least amount of time, as technically you are not required to do a
backup (though it's highly recommended you do).
• You are not prompted to enter a product key, at least for those users upgrading from
Windows 7 or Windows 8.1.

Disadvantages of upgrading
• Occasionally, upgrades have problems including errors caused by pre-existing issues in your
system.
• After the upgrade, there are chances that applications and peripherals may not work
correctly, and it could result on additional time trying to troubleshoot and fix the problems.

Note: If you are planning to upgrade, make sure to uninstall any security software, such as
antivirus, and software you do not need. Take the time and check online to verify your hardware
and software are compatible with Windows 10. Also, make sure to disconnect any peripherals, such
as printers, scanners, and USB devices to avoid possible errors.

iii) Multi-boot Installation


Another option is to install multiple operating systems on a single computer. You can install each
OS inside a different disk partition and this way every OS will have its own files and
configuration settings. On multi-boot installations, the users see a menu when they open their
computers and they have to select the desired OS. Of course, only one operating system can run
at a time.

iv) Virtualization
This is relative new technique that is often used on servers. With virtualization we can run
numerous copies of an operating system on a single set of hardware and create this way several
virtual machines. Every single virtual machine works like a separate computer. This technology
makes a single physical hardware resource to appear like multiple logical resources.
81
Pre-Installation actions
1. Make sure that all the hardware is certified to work with the new operating system.
2. Confirm that the hardware resources meet the minimum installation requirements.

Table 10: System requirements for installing Windows 10

Processor 1 gigahertz (GHz) or faster compatible processor or


System on a Chip (SoC)
RAM 1 gigabyte (GB) for 32-bit or 2 GB for 64-bit
Hard drive size 32GB or larger hard disk
Graphics card Compatible with DirectX 9 or later with WDDM 1.0
driver
Display 800x600
Internet Connection Internet connectivity is necessary to perform updates and
to download and take advantage of some features.

3. Perform a virus scan before starting the installation and a complete full backup of all
your personal data.

One method that helps you protect your data is this: Create multiple partitions on the hard disk
and install a different OS on each partition. Then copy all your data inside an empty partition that
does not contain an OS. This way you can upgrade the operating system without the risk of losing
any data. Backup and recovery of data files is also easier with this design.

4. Decide the type of file system to use.


The file system controls how the OS stores and tracks the files. There are several different file
systems available. The most well-known are: FAT 32, NTFS, HPFS, ext2 and ext3. Every
operating system is designed to use one or more of these file systems. There are advantages and
disadvantages on every file system. Careful consideration should be made to the type of file
systems supported by the selected OS and the benefits of each.
You can find several programs to modify the partitioning structure and file system of a hard drive
after installation, but it is better to avoid them if possible. When modifying either the file system
or partition structure on a hard drive, data loss may result. Careful planning can help preserve the
integrity of the data.

Windows desktop operating system installation procedure

Each version of Microsoft Windows is installed on a computer using similar steps. While there
are steps in the installation process that can differ between versions of Windows, the following
general steps and guidelines will help you to install Windows on your computer.
82
If you are replacing the hard drive in your computer, you will need to reinstall Windows again.

If you are replacing the motherboard in your computer, you may need to purchase a new licensed
copy of Windows and install it. Microsoft has designed current versions of Windows to be tied to
the motherboard in the computer when Windows is installed. So if you change the motherboard,
the existing license, or product key, may no longer be valid.

Note: If you want to upgrade to a newer version of Windows on your computer, the steps on
outlinedher can help you with the upgrade process. The Windows installation process should
recognize if you have an older version of Windows already installed on the computer and ask if
you want to upgrade or perform a fresh install. The upgrade process will install the newer
Windows operating system files over top the old ones and preserve your files.

The steps below are for all recent versions of Windows including Windows 8, and Windows 10.

First, you will need a genuine copy of the Microsoft Windows operating system installation
CD, DVD, or USB thumb drive. A genuine Windows product key is included with the
installation disc, which is required to activate Windows after installation. If you have an OEM
computer, the product key for your version of Windows is also often on the back or side of the
computer.

If you have an OEM computer (e.g., Acer, Dell, HP, etc.), the computer will not have a genuine
Windows CD, DVD, or USB thumb drive. Instead, you would reinstall Windows and all the
software using a hidden partition or a set of restore discs. The steps mentioned here would still
work, but you'd need a copy of Windows.

Note: With early versions of Windows, you cannot download a copy of Windows to install on a
computer. You must purchase a physical copy of Windows. If you are installing Windows 10,
you can download the Windows 10 creation tool to create a bootable disc or USB thumb drive.

Warning: Microsoft has Windows 10 available for download only from their website. Any other
site that claims to have copies of other versions of Windows should not be trusted. These copies
of Windows are pirated software and could contain anything including spyware or malware.

Steps:
To start the Windows install or upgrade process, you will need to configure your computer to
boot from a CD or DVD before booting to the hard drive. Changing the boot process forces the
computer to look for the Windows installation disc before trying to boot from the hard drive.

83
1. Access the computer's BIOS setup.

2. Change the computer's boot order. Set the CD, DVD or disc drive as the first boot device if
you are trying to boot from a disc. Or, set the first boot device to your USB drive if you're trying
to boot from a USB thumb drive. If the drive is not shown, keep the disc is inserted and reboot
the computer. With the disc in the drive, BIOS should recognize and include it in the list.

3. Save the settings change and exit BIOS.


Once you have updated the boot order, you can begin the Windows installation process.

4. Place the Windows disc in the CD/DVD drive or USB thumb drive into the back of the
computer.

5. Turn on or restart the computer. As the computer is starting up, it should see the installation
disc or drive and show a message similar to Press any key to boot from CD. Press any key on the
keyboard to have the computer boot from the Windows disc or drive.

6. After the Windows install begins, there are several prompts that you need to answer. Select
either Yes or the appropriate option to install Windows.

Install Note: Make sure you select the Full Install option and not the Repair or Upgrade option.

Upgrade Note: If you are upgrading to a newer version of Windows, select the Upgrade option
instead of the Full Install option.

7. When asked which partition to install Windows onto, select the main partition, which is
usually the C: drive or one labeled "Unallocated partition". If upgrading Windows, select the
existing installation of Windows on the hard drive.
8. You may be asked if you want to erase all contents on the hard drive, then install Windows.
It is recommended that you choose this option, as it will also properly format the hard drive to
allow the Windows operating system to be installed.

9. The computer may need to restart several times during the Windows install process. The
restarts are normal and if prompted to restart, select the Yes option.

10. When the install process is nearly complete, the Windows configuration option screens are
shown. On these screens, you may be asked to select the time zone you live in, your preferred
language, and the name of the account you use to access Windows. Select the appropriate options
and enter the appropriate information on each configuration screen.

The Windows install process will be complete when the computer prompts you to log in with the
account you created on the configuration screens, or when it loads directly into Windows.

84
Final Windows and computer configuration
After Windows is installed on the computer, you will need to install the drivers and related
software for the hardware in the computer. You can use the installation discs that came with the
hardware, or you can download the drivers from the hardware manufacturer's website.

Tip: If you cannot download drivers because your network card is not working after installing
Windows, you can download the drivers on another computer. Then, copy them to a USB thumb
drive, and move them over to your computer.

How to install and update a computer driver.


It is strongly recommended that you install the latest drivers for each piece of hardware.

To determine which hardware needs drivers to be installed, check the Device Manager and look
for exclamation mark "!" next to hardware devices. The exclamation point means drivers are
needed for that device.

After installing the necessary hardware device drivers, install any software programs on the
computer that you want to use.

Finally, download and install any available Windows updates. Updating Windows can help
improve the performance of the operating system, the hardware in the computer, and software
programs you use. It can also improve security by fixing potential security holes and flaws in
Windows.

Windows desktop operating system customization

Setting the date and time in Windows 10


Note: Windows 10 automatically adjusts your date and time for you and only allows you to adjust
the time if you disable this feature. If the wrong date and time are set, you need to change the
time zone, or increase or decrease the time for other reasons, follow the steps below.

1. Right-click or tap on the date and time in the Windows Notification Area in the bottom right
corner of the screen.
2. Click Adjust date/time.
3. Make sure your Time zone is set properly if your computer is displaying the wrong time.
4. To manually adjust the time, turn off the Set time automatically option and then click the
Change button.

How to configure remote desktop


To open Remote Desktop in Windows Professional, follow these steps.
• Click the Start button, type remote desktop, and click on Remote Desktop connection.
• Or, in the Start menu, click Windows Accessories, then click Remote Desktop Connection.

85
• In the remote connection window, type the computer address you want to remotely connect
to and the user name you want to use. For advanced options, like those shown below, click
Show Options at the bottom of the window.

Change Computer name


Step 1
Click the Start Button and right-click Computer and select Properties.
Note: Like all things Windows, there are several ways to do the same thing. With Windows 7 and
Vista, you can just type System and click System as shown to the right.

Step 2
First, click Change Settings.

Step 3
Click Change button under Computer Name Tab.

Step 4
Type in the new name for your computer under Computer Name Field.

Once you complete Step 4 just click OK a few times. You will be prompted to reboot the
computer, and once your reboot is complete, your new computer name will be in effect.

Customization of Licence settings


1. Use the Windows key + R keyboard shortcut to open the Run command.
2. Type slui.exe 3 and click OK to open the Windows activation client.
3. Type the 25-digit product key for the version of Windows 10 you want.
4. Click Next to complete the task.
If the activation process completes successfully, you'll get the "Windows is activated" message.

How to change Windows 10's product key using CHANGEPK


1. Use the Windows key + R keyboard shortcut to open the Run command.
2. Type changepk.exe and click OK to open the Windows activation client.
3. Enter the 25-digit product key for the version of Windows 10 you want.
4. Click Next to complete the task.

If the activation process completes successfully, you'll get the "Windows is activated" message.

Alternatively, you can use change the product key using changepk.exe using the Command
Prompt as well. Here's how:
1. Open the Start menu.
2. Search for Command Prompt.
3. Right-click the result and select Run as administrator.
4. Type the following command using your 25-digit product key and press Enter:
86
changepk.exe /Product Key<enter your 25-digit product key here>

To Configure Network settings


1. Select Start, then select Settings > Network & Internet .
2. Do one of the following:
• For a Wi-Fi network, select Wi-Fi > Manage known networks. Choose the network you
want to change the settings for, then select Properties.
• For an Ethernet network, select Ethernet, then select the Ethernet network you’re connected
to.
3. Under IP assignment, select Edit.
4. Under Edit IP settings, select Automatic (DHCP) or Manual.

Conclusion
At the end of this learning outcome, the trainee should be able to explain an operating system,
describe structures of operating systems, explain types of operating systems and demonstrate
installation of Windows operating system.

Further reading

1. Deitel, Harvey M.; Deitel, Paul; Choffnes, David. Operating Systems. Pearson/Prentice
Hall. ISBN 978-0-13-092641-8.
2. https://www.wikihow.com/Install-an-Operating-System-on-a-Brand-New-Computer
3. https://www.windowscentral.com/how-change-product-key-windows-10

3.3.2.3 Self Assessment

Written assessment
1. What is system software?
2. How do the functions of system software differ from those of application software?
3. When should one consider performing an upgrade of Windows over a clean installation?
4. Which three advantages can be associated with performing a clean installation?
5. What are the minimum processor, memory and hard drive requirements for installing Windows
10?
6. Why is it necessary to perform a backup of data and applications before installing Windows?
7. In which fields are real time operating systems used?
8. What advantage does the layered operating system structure introduce over the monolithic
structure?
9. What is a virtual machine?
87
10. Which role does the Shell play in an operating system?

Oral Assessment
1. Multiprocessor operating systems are increasingly becoming common for certain types of
tasks. Which kinds of tasks are these?
2. List and explain 5 types of windows desktop operating system installation
3. Briefly explain ,BIOS, Disk image, firmware, PrebooteXecution Environment (PXE)

Practical Assessment
Install and configure Windows 10 desktop operating system on a 500GB hard disk. Partition this
hard drive into two equal partitions.

3.3.2.4 Tools, equipment, supplies and materials


• Computer
• Internet connectivity
• Windows Set Up file
• Stationery
• Instruction material

3.3.2.5 References

1. Computer - Software. Retrieved from


https://www.tutorialspoint.com/computer_fundamentals/computer_software.htm
2. Layered Operating Systems. Retrieved from https://www.tutorialspoint.com/layered-
operating-system
3. Windows 10 specifications. Retrieved from https://www.microsoft.com/en-
us/windows/windows-10-specifications
4. https://pcdreams.com.sg/operating-system-options-and-installation-methods/
5. https://www.windowscentral.com/how-change-product-key-windows-10

88
3.3.3 Learning Outcome 2: Understand Process Management
3.3.3.1 Learning Activities
Learning Outcome 2: Understand Process Management
Learning Activities Special Instructions

2.1 Process management is explained ● Activities may be carried out in


2.2 Manage computer resources groups or as individual
2.3 Process states and transitions are explained
2.4 Process scheduling is explained
2.5 Use of the Task Manager is demonstrated
2.6 Use of performance monitor tool is demonstrated

3.3.2.2 Information sheet No 3/LO2: Understand Process Management

Introduction
This learning outcome covers process management. It entails explaining process management,
managing computer resources, explaining process state and transitions, explaining process
scheduling, using the task manager and using the performance monitor tool.

Introduction to Process Management

The Process Concept


A process is basically a program in execution. The execution of a process must progress in a
sequential fashion.

Definition: A process is defined as an entity which represents the basic unit of work to be
implemented in the system.

To put it in simple terms, we write our computer programs in a text file and when we execute this
program, it becomes a process which performs all the tasks mentioned in the program.

When a program is loaded into the memory and it becomes a process, it can be divided into four
sections ─ stack, heap, text and data. The following image shows a simplified layout of a process
inside main memory −

89
Figure 31:Layout of a process inside main memory

Component & Description

1 Stack
The process Stack contains the temporary data such as method/function parameters,
return address and local variables.

2 Heap
This is dynamically allocated memory to a process during its run time.

3 Text
This includes the current activity represented by the value of Program Counter and
the contents of the processor's registers.

4 Data
This section contains the global and static variables.

Program Concept
A program is a piece of code which may be a single line or millions of lines. A computer program
is usually written by a computer programmer in a programming language. For example, here is a
simple program written in C programming language –

#include <stdio.h>

90
int main() {
printf("Hello, World! \n");
return 0;
}
A computer program is a collection of instructions that performs a specific task when executed by
a computer. When we compare a program with a process, we can conclude that a process is a
dynamic instance of a computer program.

A part of a computer program that performs a well-defined task is known as an algorithm. A


collection of computer programs, libraries and related data are referred to as a software.

Process Management
The process manager is the OS module that allocates resources to processes, enables processes to
share and exchange information, protect the resources of each process from other processes and
enable synchronization among processes.
Process States and Transition
When a process executes, it passes through different states. These stages may differ in different
operating systems, and the names of these states are also not standardized.

In general, a process can have one of the following five states at a time.
State & Description

1 Start
This is the initial state when a process is first started/created.

2 Ready
The process is waiting to be assigned to a processor. Ready processes are waiting
to have the processor allocated to them by the operating system so that they can
run. Process may come into this state after Start state or while running it by but
interrupted by the scheduler to assign CPU to some other process.

3 Running
Once the process has been assigned to a processor by the OS scheduler, the process
state is set to running and the processor executes its instructions.

4 Waiting
Process moves into the waiting state if it needs to wait for a resource, such as
waiting for user input, or waiting for a file to become available.

5 Terminated or Exit
Once the process finishes its execution, or it is terminated by the operating system,
it is moved to the terminated state where it waits to be removed from main
memory.
91
Figure 32:Process States and Transition

Process Control Block (PCB)


A Process Control Block is a data structure maintained by the Operating System for every process.
The PCB is identified by an integer process ID (PID). A PCB keeps all the information needed to
keep track of a process as listed below in the table −
Information & Description

1 Process State
The current state of the process i.e., whether it is ready, running, waiting, or
whatever.

2 Process privileges
This is required to allow/disallow access to system resources.

3 Process ID
Unique identification for each of the process in the operating system.

4 Pointer
A pointer to parent process.

5 Program Counter
Program Counter is a pointer to the address of the next instruction to be executed
for this process.

6 CPU registers
Various CPU registers where process need to be stored for execution for running
state.

7 CPU Scheduling Information


Process priority and other scheduling information which is required to schedule
the process.

92
8 Memory management information
This includes the information of page table, memory limits, and Segment table
depending on memory used by the operating system.

9 Accounting information
This includes the amount of CPU used for process execution, time limits,
execution ID etc.

10 IO status information
This includes a list of I/O devices allocated to the process.

The architecture of a PCB is completely dependent on Operating System and may contain different
information in different operating systems. Here is a simplified diagram of a PCB −

Figure 33:Process Control Block (PCB)

The PCB is maintained for a process throughout its lifetime, and is deleted once the process
terminates.

Managing Computer Resources


Processes need two key resources such as the processor or CPU and storage space (main memory
and disk). In a multiprogramming environment, several processes constantly request to use these
resources and therefore a sharing mechanism for the CPU and other resources needs to be in
place to meet the needs the needs of each process so that it can be scheduled and be completed on
time.

Types of Processes
Processes can be described as either:
• I/O-bound process – spends more time doing I/O than computations, many short CPU
bursts.
93
• CPU-bound process – spends more time doing computations; few very long CPU bursts.

Process Scheduling
The process scheduling is the activity of the process manager that handles the removal of the
running process from the CPU and the selection of another process on the basis of a particular
strategy.

Process scheduling is an essential part of multiprogramming operating systems. Such operating


systems allow more than one process to be loaded into the executable memory at a time and the
loaded process shares the CPU using time multiplexing.

Process Scheduling Queues


The OS maintains all PCBs in Process Scheduling Queues. The OS maintains a separate queue for
each of the process states and PCBs of all processes in the same execution state are placed in the
same queue. When the state of a process is changed, its PCB is unlinked from its current queue and
moved to its new state queue.

The Operating System maintains the following important process scheduling queues −
• Job queue − this queue keeps all the processes in the system.
• Ready queue − this queue keeps a set of all processes residing in main memory, ready and
waiting to execute. A new process is always put in this queue.
• Device queues − the processes which are blocked due to unavailability of an I/O device
constitute this queue.

Figure 34:Process Scheduling Queues

The OS can use different policies to manage each queue (FIFO, Round Robin, Priority, etc.). The
OS scheduler determines how to move processes between the ready and run queues which can
only have one entry per processor core on the system; in the above diagram, it has been merged
with the CPU.

94
Two-State Process Model
Two-state process model refers to running and non-running states which are described below −
. State & Description

1 Running
When a new process is created, it enters into the system as in the running state.

2 Not Running
Processes that are not running are kept in queue, waiting for their turn to execute.
Each entry in the queue is a pointer to a particular process. Queue is implemented
by using linked list.

Use of dispatcher is as follows. When a process is interrupted, that process is


transferred in the waiting queue. If the process has completed or aborted, the
process is discarded. In either case, the dispatcher then selects a process from the
queue to execute.

Schedulers
Schedulers are special system software which handle process scheduling in various ways. Their
main task is to select the jobs to be submitted into the system and to decide which process to run.
Schedulers are of three types −
• Long-Term Scheduler
• Short-Term Scheduler
• Medium-Term Scheduler

Long Term Scheduler


It is also called a job scheduler. A long-term scheduler determines which programs are admitted
to the system for processing. It selects processes from the queue and loads them into memory for
execution. Process loads into the memory for CPU scheduling.

The primary objective of the job scheduler is to provide a balanced mix of jobs, such as I/O bound
and processor bound. It also controls the degree of multiprogramming. If the degree of
multiprogramming is stable, then the average rate of process creation must be equal to the average
departure rate of processes leaving the system.

On some systems, the long-term scheduler may not be available or minimal. Time-sharing
operating systems have no long term scheduler. When a process changes the state from new to
ready, then there is use of long-term scheduler.

Short Term Scheduler


It is also called as CPU scheduler. Its main objective is to increase system performance in
accordance with the chosen set of criteria. It is the change of ready state to running state of the

95
process. CPU scheduler selects a process among the processes that are ready to execute and
allocates CPU to one of them.

Short-term schedulers, also known as dispatchers, make the decision of which process to execute
next. Short-term schedulers are faster than long-term schedulers.

Medium Term Scheduler


Medium-term scheduling is a part of swapping. It removes the processes from the memory. It
reduces the degree of multiprogramming. The medium-term scheduler is in-charge of handling the
swapped out-processes.

A running process may become suspended if it makes an I/O request. A suspended processes
cannot make any progress towards completion. In this condition, to remove the process from
memory and make space for other processes, the suspended process is moved to the secondary
storage. This process is called swapping, and the process is said to be swapped out or rolled out.
Swapping may be necessary to improve the process mix.

Table 11: Comparison among Schedulers

Long-Term Scheduler Short-Term Scheduler Medium-Term Scheduler

1 It is a job scheduler It is a CPU scheduler It is a process swapping


scheduler.

2 Speed is lesser than Speed is fastest among Speed is in between both


short term scheduler other two short and long term
scheduler.

3 It controls the degree of It provides lesser control It reduces the degree of


multiprogramming over degree of multiprogramming.
multiprogramming

4 It is almost absent or It is also minimal in time It is a part of Time sharing


minimal in time sharing sharing system systems.
system

5 It selects processes from It selects those processes It can re-introduce the


pool and loads them which are ready to execute process into memory and
into memory for execution can be continued.
execution
Context Switching
A context switch is the mechanism to store and restore the state or context of a CPU in Process
Control block so that a process execution can be resumed from the same point at a later time.

96
Using this technique, a context switcher enables multiple processes to share a single CPU. Context
switching is an essential part of a multitasking operating system features.

When the scheduler switches the CPU from executing one process to execute another, the state
from the current running process is stored into the process control block. After this, the state for
the process to run next is loaded from its own PCB and used to set the PC, registers, etc. At that
point, the second process can start executing.

Figure 35:Context Switching

Context switches are computationally intensive since register and memory state must be saved and
restored. To avoid the amount of context switching time, some hardware systems employ two or
more sets of processor registers.

When the process is switched, the following information is stored for later use.
• Program Counter
• Scheduling information
• Base and limit register value
• Currently used register
• Changed State
• I/O State information
• Accounting information

97
Operating System scheduling algorithms
A Process Scheduler schedules different processes to be assigned to the CPU based on particular
scheduling algorithms.

There are six popular process scheduling algorithms


• First-Come, First-Served (FCFS) Scheduling
• Shortest-Job-Next (SJN) Scheduling
• Priority Scheduling
• Shortest Remaining Time
• Round Robin(RR) Scheduling
• Multiple-Level Queues Scheduling

These algorithms are either non-preemptive or preemptive. Non-preemptive algorithms are


designed so that once a process enters the running state, it cannot be preempted until it completes
its allotted time, whereas the preemptive scheduling is based on priority where a scheduler may
preempt a low priority running process anytime when a high priority process enters into a ready
state.

First Come First Serve (FCFS)


• Jobs are executed on first come, first serve basis.
• It is a non-preemptive, pre-emptive scheduling algorithm.
• Easy to understand and implement.
• Its implementation is based on FIFO queue.
• Poor in performance as average wait time is high.

Wait time of each process is as follows −


Process Wait Time : Service Time - Arrival Time

98
P0 0-0=0

P1 5-1=4

P2 8-2=6

P3 16 - 3 = 13
Average Wait Time: (0+4+6+13) / 4 = 5.75

Shortest Job Next (SJN)


• This is also known as shortest job first, or SJF
• This is a non-preemptive, pre-emptive scheduling algorithm.
• Best approach to minimize waiting time.
• Easy to implement in Batch systems where required CPU time is known in advance.
• Impossible to implement in interactive systems where required CPU time is not known.
• The processer should know in advance how much time process will take.

Given: Table of processes, and their Arrival time, Execution time


Process Arrival Time Execution Time Service Time

P0 0 5 0

P1 1 3 5

P2 2 8 14

P3 3 6 8

Waiting time of each process is as follows −


Process Waiting Time

P0 0-0=0

P1 5-1=4

P2 14 - 2 = 12

P3 8-3=5
Average Wait Time: (0 + 4 + 12 + 5)/4 = 21 / 4 = 5.25

Priority Based Scheduling

99
• Priority scheduling is a non-preemptive algorithm and one of the most common scheduling
algorithms in batch systems.
• Each process is assigned a priority. Process with highest priority is to be executed first and
so on.
• Processes with same priority are executed on first come first served basis.
• Priority can be decided based on memory requirements, time requirements or any other
resource requirement.

Given: Table of processes, and their Arrival time, Execution time, and priority. Here we are
considering 1 is the lowest priority.
Process Arrival Time Execution Time Priority Service Time

P0 0 5 1 0

P1 1 3 2 11

P2 2 8 1 14

P3 3 6 3 5

Waiting time of each process is as follows −


Process Waiting Time

P0 0-0=0

P1 11 - 1 = 10

P2 14 - 2 = 12

P3 5-3=2
Average Wait Time: (0 + 10 + 12 + 2)/4 = 24 / 4 = 6

Shortest Remaining Time


• Shortest remaining time (SRT) is the preemptive version of the SJN algorithm.
• The processor is allocated to the job closest to completion but it can be preempted by a
newer ready job with shorter time to completion.
• Impossible to implement in interactive systems where required CPU time is not known.
• It is often used in batch environments where short jobs need to give preference.

Round Robin Scheduling


• Round Robin is the preemptive process scheduling algorithm.
• Each process is provided a fix time to execute, it is called a quantum.

100
• Once a process is executed for a given time period, it is preempted and other process
executes for a given time period.
• Context switching is used to save states of preempted processes.

Wait time of each process is as follows −


Process Wait Time : Service Time - Arrival Time

P0 (0 - 0) + (12 - 3) = 9

P1 (3 - 1) = 2

P2 (6 - 2) + (14 - 9) + (20 - 17) = 12

P3 (9 - 3) + (17 - 12) = 11
Average Wait Time: (9+2+12+11) / 4 = 8.5

Multiple-Level Queues Scheduling


Multiple-level queues are not an independent scheduling algorithm. They make use of other
existing algorithms to group and schedule jobs with common characteristics.
• Multiple queues are maintained for processes with common characteristics.
• Each queue can have its own scheduling algorithms.
• Priorities are assigned to each queue.
For example, CPU-bound jobs can be scheduled in one queue and all I/O-bound jobs in another
queue. The Process Scheduler then alternately selects jobs from each queue and assigns them to
the CPU based on the algorithm assigned to the queue.

Using the Windows 10 Task Manager: An overview


The Windows Task Manager is a powerful tool packed with useful information, from your
system’s overall resource usage to detailed statistics about each process

How to Launch the Task Manager


The simplest one is pressing Ctrl+Alt+Delete and then click “Task Manager” on the screen that
appears or find the Task Manager shortcut in your Start menu.

The first time you launch the Task Manager, you’ll see a small, simple window.

101
Figure 36: Task Manager (Start window)

This window lists the visible applications running on your desktop, excluding background
applications. You can select an application here and click “End Task” to close it. This is useful if an
application isn’t responding—in other words, if it’s frozen—and you can’t close it the usual way.

You can also right-click an application in this window to access more options:
• Switch To: Switch to the application’s window, bringing it to the front of your desktop and
putting it in focus. This is useful if you’re not sure which window is associated with which
application.
• End Task: End the process. This works the same as the “End Task” button.
• Run New Task: Open the Create New Task window, where you can specify a program, folder,
document, or website address and Windows will open it.
• Always On Top: Make the Task Manager window itself “always on top” of other windows on
your desktop, letting you see it at all times.
• Open File Location: Open a File Explorer window showing the location of the program’s
.exe file.
• Search Online: Perform a Bing search for the program’s application name and file name. This
will help you see exactly what the program is and what it does.
• Properties: Open the Properties window for the program’s .exe file. Here you can tweak
compatibility options and see the program’s version number, for example.

The Task Manager’s Tabs

102
Figure 37:Task Manager Details window

To see the Task Manager’s more advanced tools, click “More Details” at the bottom of the simple
view window.

You’ll see the full, tabbed interface appear. The Task Manager will remember your preference and
will open to the more advanced view in the future. If you want to get back to the simple view, click
“Fewer Details.”

With More Details selected, the Task Manager includes the following tabs:
• Processes: A list of running applications and background processes on your system along with
CPU, memory, disk, network, GPU, and other resource usage information.
• Performance: Real-time graphs showing total CPU, memory, disk, network, and GPU resource
usage for your system. You’ll find many other details here, too, from your computer’s IP
address to the model names of your computer’s CPU and GPU.
• App History: Information about how much CPU and network resources apps have used for your
current user account. This only applies to new Universal Windows Platform (UWP) apps—in
other words, Store apps—and not traditional Windows desktop apps (Win32 applications.)
• Startup: A list of your startup programs, which are the applications Windows automatically
starts when you sign into your user account. You can disable startup programs from here,
although you can also do that from Settings > Apps > Startup.
• Users: The user accounts currently signed into your PC, how much resources they’re using, and
what applications they’re running.

103
• Details: More detailed information about the processes running on your system. This is basically
the traditional “Processes” tab from the Task Manager on Windows 7.
• Services: Management of system services. This is the same information you’ll find in
services.msc, the Services management console.

Managing Processes
The Processes tab shows you a comprehensive list of processes running on your system. If you sort
it by name, the list is broken into three categories. The Apps group shows the same list of running
applications you’d see in the “Fewer details” simplified view. The other two categories are
background processes and Windows processes, and they show processes that don’t appear in the
standard simplified Task Manager view.

For example, tools like your antivirus program, background update processes, and hardware utilities
with notification area (system tray) icons appear in the background processes list.

Windows processes include various processes that are part of the Windows operating system,
although some of these appear under “Background processes” instead.

You can right-click a process to see actions you can perform. The options you’ll see in the context
menu are:
• Expand: Some applications, like Google Chrome, have multiple processes are grouped
here. Other applications have multiple windows that are part of a single process. You can select
expand, double-click the process, or click the arrow to its left to see the entire group of processes
individually. This option only appears when you right-click a group.
• Collapse: Collapse an expanded group.
• End task: End the process. You can also click the “End Task” button below the list.
• Restart: This option only appears when you right-click Windows Explorer. It lets you
restart explorer.exe instead of simply ending the task.

104
• Resource values: Lets you choose whether you want to see the percentage or precise values for
memory, disk, and network. In other words, you can choose whether you want to see the precise
amount of memory in MB or the percentage of your system’s memory applications are using.
• Create dump file: This is a debugging tool for programmers. It captures a snapshot of the
program’s memory and saves it to disk.
• Go to details: Go to the process on the Details tab so you can see more detailed technical
information.
• Open file location: Open File Explorer with the process’s .exe file selected.
• Search online: Search for the name of the process on Bing.
• Properties: View the Properties window of the .exe file associated with the process.

You should not end tasks unless you know what the task does. Many of these tasks are background
processes important to Windows itself.

Task Manager Menu Options

There are also a few useful options in the Task Manager’s menu bar:
• File > Run New Task: Launch a program, folder, document, or network resource by providing
its address. You can also check “Create this task with administrative privileges” to launch the
program as Administrator.
• Options > Always on Top: The Task Manager window will always be on top of other windows
while this option is enabled.
• Options > Minimize on Use: The Task Manager will be minimized whenever you right-click a
process and select “Switch To.” Despite the odd name, that’s all this option does.
• Options > Hide When Minimized: The Task Manager will stay running in the notification area
(system tray) when you click the minimize button if you enable this option.
• View > Refresh Now: Immediately refresh the data displayed in the Task Manager.

105
• View > Update Speed: Choose how frequently the data displayed in the Task Manager is
updated: High, Medium, Low, or Paused. With Paused selected, the data isn’t updated until you
select a higher frequency or click “Refresh Now.”
• View > Group By Type: With this option enabled, processes on the Processes tab are grouped
into three categories: Apps, Background Processes, and Windows Processes. With this option
disabled, they’re shown mixed in the list.
• View > Expand All: Expand all the process groups in the list. For example, Google Chrome
uses multiple processes, and they’re shown combined into a “Google Chrome” group. You can
expand individual process groups by clicking the arrow to the left of their name, too.
• View > Collapse All: Collapse all the process groups in the list. For example, all Google
Chrome processes will just be shown under the Google Chrome category.

Using the Windows 10 Performance Monitor


When your computer suddenly isn't fast as usual, or keeps hanging, you're likely dealing with
performance issues that could be caused by a number of reasons.

It could be as a result of problems with the hardware, apps or drivers poorly designed, the operating
system using excessive system resources, or even be a malware that infected your device.

In Windows 10, Performance Monitor is one of the most popular tools used to view and analyze
application and hardware data and to solve system performance related problems. You can also
customize what data to collect in log files, define alerts, generate reports, and replay collected
performance data in many ways.

How to open Performance Monitor


Here are three ways to open Performance Monitor:
• Open Start, do a search for Performance Monitor, and click the result.
• Use the Windows key + R keyboard shortcut to open the Run command, type perfmon,
and click OK to open.
• Use the Windows key + X keyboard shortcut to open the Power User menu,
select Computer Management, and click on Performance

How to use Performance Monitor


When you first open the tool, it'll open in the main page with a brief overview, as well as a system
summary with real-time data about memory, network adapter, physical disk, and processor usage.

106
Figure 38:Performance Monitor

On the left, you'll find the navigation pane with access to Performance Monitor, Data Collector
Sets, and Reports.

Switching to Performance Monitor, you'll see a screen with a single counter. This is typically the
"Processor Time" counter, which displays the processor load in the last 100 seconds. However, the
advantage of this tool is that you can add many other counters to monitor virtually anything on your
computer.

Adding new counters

107
To add new counters to monitor applications and hardware performance on your computer, do the
following:
1. Click the green plus button above the Performance Monitor graph.

2. Select Local computer or the name of your computer from the drop-down menu.
3. Select and expand the category of the item you want to monitor. For example, for the purpose of
this guide, select the "Network Adapter" category.
4. Select the counters you want to monitor (e.g., Bytes Total/sec).
Quick Tip: If you're trying to add multiple counters, press and hold the Ctrl key and click to select
each item you want to add. Also, you can check the Show description option to get more
information about the counter you're selecting.
5. If applicable, select the instances you want to monitor. For example, on Network Adapter, you can
monitor one or multiple network adapters simultaneously.
6. Click the Add button.

7. Click OK to confirm and add the new counters.

108
Customizing Performance Monitor view
Once you have configured all the counters you want to monitor, you can also customize various
aspects of the data shown in the graph.

To customize the Performance Monitor view, do the following:


1. Double-click one of the counters to open the Performance Monitor Properties window.
2. On the "Data" tab, select the counter you want to customize.
3. At the bottom, choose the color, scale, width, and style you want to use.
4. Repeat steps 2 and 3 for each item you want to customize.

Quick Tip: If you're trying to change the properties for multiple counters, press and hold
the Ctrl key, select each item you want to customize, and change the available settings.
5. Click Apply.
6. Click OK.
In addition, you can also change the graph's style, simply click the "Change graph type" in the
toolbar and select one of the available views, including Line, Histogram bar, and Report.

Conclusion
At the end of this learning outcome, the learner should be able to explain process management,
manage computer resources, illustrate process state and transitions, explain process scheduling,
use the task manager and use the performance monitor tool.

Further Reading

• Remzi H. Arpaci-Dusseau and Andrea C. Arpaci-Dusseau (2014). "Operating


Systems: Three Easy Pieces". Arpaci-Dusseau Books. Relevant chapters: Abstraction: The
Process The Process API

109
• Gary D. Knott (1974) A proposal for certain process management and
intercommunication primitives ACM SIGOPS Operating Systems Review. Volume 8, Issue 4
(October 1974). pp. 7 – 44

3.3.2.3 Self assessment

Written Assessment
1. What is a process?
2. How does a program differ from a process?
3. What is the role of the process manager?
4. Which are the three schedulers used for transitioning jobs from disk to memory to the CPU?
5. What range of information is contained in the Process Control Block?
6. Which resources are involved in a multiprogramming environment?
7. Why is context switching considered undesirable in process scheduling?
8. Identify two tasks you can perform with the Task Manager in Windows.
9. What it the role of the Performance Monitor in Windows?
10. Under what circumstances is a new process created?

Oral Assessment
A blocked process is usually waiting for I/O. What are some of the I/O devices involved in the
blocked state?
.
Practical Assessment
Open the task manager and identify processes that are high CPU users and the idle processes.

3.3.2.4 Tools, Equipment, Supplies and Materials


• Computer
• Internet Connectivity
• Stationery
• Instruction material

3.3.2.5 References

1. Silberschatz, Abraham; Cagne, Greg; Galvin, Peter Baer (2004). "Chapter 4. Processes".
Operating system concepts with Java (Sixth Ed.). John Wiley & Sons. ISBN 0-471-48905-0.
2. Stallings, William (2005). Operating Systems: internals and design principles (5th Ed.).
Prentice Hall. ISBN 0-13-127837-1. (Particularly chapter 3, section 3.2, "process states",
including figure 3.9 "process state transition with suspend states")
4. https://www.tutorialspoint.com/operating_system

110
3.3.4 Learning Outcome 3: Understand Memory Management
3.3.4.1 Learning Activities
Learning Outcome 3: Understand Memory Management
Learning Activities Special Instructions

3.1 Memory management is explained. ● Activities may be carried out in


3.2 Memory management techniques are explained. groups or as individual
3.3 Virtual memory management settings are demonstrated

3.3.4.2 Information sheet No 3/LO3: Understand Memory Management

Introduction
This learning outcome covers memory management. It entails explaining management, explaining
memory management techniques and demonstrating virtual memory settings.

Introduction to memory management


Together with the CPU, the physical memory is the most important resource a computer has. The
CPU chip has instructions to manipulate data only directly in memory, so all arithmetic and logic
operations must take place in RAM.

Memory management is the functionality of an operating system which handles or manages


primary memory and moves processes back and forth between main memory and disk during
execution.

Memory management keeps track of each and every memory location, regardless of either it is
allocated to some process or it is free. It checks how much memory is to be allocated to processes.
It decides which process will get memory at what time. It tracks whenever some memory gets freed
or unallocated and correspondingly it updates the status.

Process Address Space


The process address space is the set of logical addresses that a process references in its code. For
example, when 32-bit addressing is in use, addresses can range from 0 to 0x7fffffff; that is, 2^31
possible numbers, for a total theoretical size of 2 gigabytes.

The operating system takes care of mapping the logical addresses to physical addresses at the time
of memory allocation to the program. There are three types of addresses used in a program before
and after memory is allocated
Memory Addresses & Description

1 Symbolic addresses

111
The addresses used in a source code. The variable names, constants, and instruction
labels are the basic elements of the symbolic address space.

2 Relative addresses
At the time of compilation, a compiler converts symbolic addresses into relative
addresses.

3 Physical addresses
The loader generates these addresses at the time when a program is loaded into main
memory.

Virtual and physical addresses are the same in compile-time and load-time address-binding
schemes. Virtual and physical addresses differ in execution-time address-binding scheme.

The set of all logical addresses generated by a program is referred to as a logical address space.
The set of all physical addresses corresponding to these logical addresses is referred to as
a physical address space.

The runtime mapping from virtual to physical address is done by the memory management unit
(MMU) which is a hardware device.

Swapping
Swapping is a mechanism in which a process can be swapped temporarily out of main memory (or
move) to secondary storage (disk) and make that memory available to other processes. At some
later time, the system swaps back the process from the secondary storage to main memory.

Though performance is usually affected by swapping process but it helps in running multiple and
big processes in parallel and that's the reason swapping is also known as a technique for memory
compaction.

Figure 39: Process Swapping in memory

112
The total time taken by swapping process includes the time it takes to move the entire process to a
secondary disk and then to copy the process back to memory, as well as the time the process takes
to regain main memory.

Let us assume that the user process is of size 2048KB and on a standard hard disk where swapping
will take place has a data transfer rate around 1 MB per second. The actual transfer of the 1000K
process to or from memory will take

2048KB / 1024KB per second = 2 seconds = 2000 milliseconds

Now considering in and out time, it will take complete 4000 milliseconds plus other overhead
where the process competes to regain main memory.

Memory Allocation
Main memory usually has two partitions −
• Low Memory − Operating system resides in this memory.
• High Memory − User processes are held in high memory.

Fragmentation
As processes are loaded and removed from memory, the free memory space is broken into little
pieces. It happens after sometimes that processes cannot be allocated to memory blocks
considering their small size and memory blocks remains unused. This problem is known as
Fragmentation.

Fragmentation is of two types −


Fragmentation & Description

1 External fragmentation
Total memory space is enough to satisfy a request or to reside a process in it, but it
is not contiguous, so it cannot be used.

2 Internal fragmentation
Memory block assigned to process is bigger. Some portion of memory is left
unused, as it cannot be used by another process.

The following diagram shows how fragmentation can cause waste of memory and a compaction
technique can be used to create more free memory out of fragmented memory −

113
Figure 40: Memory fragmentation

External fragmentation can be reduced by compaction or shuffle memory contents to place all free
memory together in one large block. To make compaction feasible, relocation should be dynamic.
The internal fragmentation can be reduced by effectively assigning the smallest partition but large
enough for the process.

Memory Management Techniques


The following are the three key memory management techniques used by an operating system:
• Paging
• Segmentation
Paging
A computer can address more memory than the amount physically installed on the system. This
extra memory is actually called virtual memory and it is a section of a hard that's set up to emulate
the computer's RAM. Paging technique plays an important role in implementing virtual memory.

Paging is a memory management technique in which process address space is broken into blocks
of the same size called pages (size is power of 2, between 512 bytes and 8192 bytes). The size of
the process is measured in the number of pages.

Similarly, main memory is divided into small fixed-sized blocks of (physical) memory
called frames and the size of a frame is kept the same as that of a page to have optimum utilization
of the main memory and to avoid external fragmentation.

External fragmentation can be reduced by compaction or shuffle memory contents to place all free
memory together in one large block. To make compaction feasible, relocation should be dynamic.

114
The internal fragmentation can be reduced by effectively assigning the smallest partition but large
enough for the process.

Figure 41: Memory paging

Address Translation
• Page address is called logical address and represented by page number and the offset.
• Logical Address = Page number + page offset
• Frame address is called physical address and represented by a frame number and
the offset.
• Physical Address = Frame number + page offset
• A data structure called page map table is used to keep track of the relation between a page
of a process to a frame in physical memory.

Figure 42: Memory Address Translation


115
When the system allocates a frame to any page, it translates this logical address into a physical
address and create entry into the page table to be used throughout execution of the program.

When a process is to be executed, its corresponding pages are loaded into any available memory
frames. Suppose you have a program of 8Kb but your memory can accommodate only 5Kb at a
given point in time, then the paging concept will come into picture.

When a computer runs out of RAM, the operating system (OS) will move idle or unwanted pages
of memory to secondary memory to free up RAM for other processes and brings them back when
needed by the program.

This process continues during the whole execution of the program where the OS keeps removing
idle pages from the main memory and write them onto the secondary memory and bring them back
when required by the program.

Advantages of Paging
Here is a list of advantages and disadvantages of paging −
• Paging reduces external fragmentation, but still suffer from internal fragmentation.
• Paging is simple to implement and assumed as an efficient memory management technique.
• Due to equal size of the pages and frames, swapping becomes very easy.

Disadvantage of paging
• Page table requires extra memory space, so may not be good for a system having small
RAM.

Segmentation
Segmentation is a memory management technique in which each job is divided into several
segments of different sizes, one for each module that contains pieces that perform related
functions. Each segment is actually a different logical address space of the program.

When a process is to be executed, its corresponding segmentation are loaded into non-contiguous
memory though every segment is loaded into a contiguous block of available memory.

Segmentation memory management works very similar to paging but here segments are of
variable-length where as in paging pages are of fixed size.

A program segment contains the program's main function, utility functions, data structures, and so
on. The operating system maintains a segment map table for every process and a list of free
memory blocks along with segment numbers, their size and corresponding memory locations in
main memory.

For each segment, the table stores the starting address of the segment and the length of the
segment. A reference to a memory location includes a value that identifies a segment and an offset.

116
Figure 43:Segmentation

Virtual Memory
A computer can address more memory than the amount physically installed on the system. This
extra memory is actually called virtual memory and it is a section of a hard disk that's set up to
emulate the computer's RAM.

The main visible advantage of this scheme is that programs can be larger than physical memory.
Virtual memory serves two purposes. First, it allows us to extend the use of physical memory by
using disk. Second, it allows us to have memory protection, because each virtual address is
translated to a physical address.

Following are the situations, when entire program is not required to be loaded fully in main
memory.
• User written error handling routines are used only when an error occurred in the data or
computation.
• Certain options and features of a program may be used rarely.
• Many tables are assigned a fixed amount of address space even though only a small amount
of the table is actually used.
• The ability to execute a program that is only partially in memory would counter many
benefits.
• Less number of I/O would be needed to load or swap each user program into memory.
• A program would no longer be constrained by the amount of physical memory that is
available.
• Each user program could take less physical memory, more programs could be run the same
time, with a corresponding increase in CPU utilization and throughput.

117
Modern microprocessors intended for general-purpose use, a memory management unit, or MMU,
is built into the hardware. The MMU's job is to translate virtual addresses into physical addresses.
A basic example is given below −

Figure 44:Virtual Memory

Virtual memory is commonly implemented by demand paging. It can also be implemented in a


segmentation system. Demand segmentation can also be used to provide virtual memory.

Demand Paging
A demand paging system is quite similar to a paging system with swapping where processes reside
in secondary memory and pages are loaded only on demand, not in advance.

When a context switch occurs, the operating system does not copy any of the old program’s pages
out to the disk or any of the new program’s pages into the main memory Instead, it just begins
executing the new program after loading the first page and fetches that program’s pages as they are
referenced.

118
Figure 45:Demand Paging

While executing a program, if the program references a page which is not available in the main
memory because it was swapped out a little ago, the processor treats this invalid memory reference
as a page fault and transfers control from the program to the operating system to demand the page
back into the memory.

Advantages of Demand Paging


• Large virtual memory.
• More efficient use of memory.
• There is no limit on degree of multiprogramming.

Disadvantages of Demand Paging


• Number of tables and the amount of processor overhead for handling page interrupts are
greater than in the case of the simple paged management techniques.

Virtual Memory Configuration in Windows 10


On Windows 10, virtual memory (or paging file) is an essential component (hidden file) designed to
remove and temporarily store less frequently use modified pages allocated in RAM (random-access
memory) to the hard drive.

Using this approach allows the system to prioritize faster physical memory for more frequent
processes and applications, improving the overall performance and preventing the device from
locking up in the event it runs out of system memory.

In addition, the paging file is important to support crash dumps during a system crash (Blue Screen
of Death), as without a large enough page file, a dump with all the contents of the system memory
won't be created.

How to increase virtual memory using Settings

To adjust the virtual memory size on Windows 10, use these steps:

Note: Although anyone can change the paging file size, it's only recommended to use these
instructions if you have a valid reason, and you know what you're doing.

1. Open Settings.
2. Click on System.
3. Click on About.
4. Under the "Related settings" section, click the System info option.

119
5. Click the "Advanced system settings" option from the left pane.

6. Click the Advanced tab.


7. Under the "Performance" section, click the Settings button

120
8. Click the Advanced tab.
9. Under the "Virtual memory" section, click the Change button.

10. Clear the Automatically manage paging files size for all drives option.
11. Select the Custom size option.
12. Specify the initial and maximum size for the paging file in megabytes.

121
Note: The size of the virtual memory is unique to each device, and it can't be generalized. However,
usually, it's recommended to use a number that's one and a half times the total available memory for
the "Initial size" and three times of available memory for the "Maximum size" when possible.
13. Click the Set button.
14. Click the OK button.
15. Click the OK button again.
16. Restart your device.

Once you complete the steps, you should notice an increase in performance when navigating
Windows 10 as well as when running multiple apps at the same time.

If you need to revert the changes, you can use the same instructions, but on step No. 10, make sure
to check the Automatically manage paging size for all drives option, and restart your device.

How to increase virtual memory using Command Prompt

To modify the paging file size with Command Prompt, use these steps:
1. Open Start.
2. Search for Command Prompt, right-click the top result, and select the Run as
administrator option.
3. Type the following command to understand the current status of the paging file and press Enter:
wmic pagefile list /format:list

122
4. Type the following command to switch form manage to custom virtual memory and press Enter:
wmic computersystem where name="%computername%" set
AutomaticManagedPagefile=false

5. Type the following command to set the initial and maximum size of the virtual memory and
press Enter:

wmic pagefileset where name="C:\\pagefile.sys" set


InitialSize=YOUR-INIT-SIZE, MaximumSize=YOUR-MAX-SIZE

This example sets the paging file to "9216" and "12288" megabytes for the initial and maxium size:

wmic pagefileset where name="C:\\pagefile.sys" set


InitialSize=9216, MaximumSize=12288

123
6. Type the following command to restart your computer and press Enter:
shutdown -r -t 00

• After you complete the steps, the device will start using the new values for virtual memory,
which, if done correctly, should help to improve system performance.

• If you no longer need to use the custom size for virtual memory, you can always revert the
changes and allow Windows 10 to manage this feature using this command: wmic
computersystem where name="%computername%" set
AutomaticManagedPagefile=true and restarting your device.

• While it's recommended to use one and a half times the available memory for the initial and
three times the memory for the maximum size, make sure to test the changes and adjust the
values if you're experiencing freezes, crashes, and other problems.

• Although it's possible to disable virtual memory on Windows 10, even when you have a
large amount of system memory, it's not recommended to disable this feature. Usually, if
you disable paging file, some applications may stop working, some system features may not
work efficiently, and you may end up with some abnormal behaviour.

Conclusion
At the end of this learning outcome, the learner should be able to explain memory management,
illustrate memory management techniques and demonstrate virtual memory management settings

Further Reading

https://www.tutorialspoint.com/operating_system

124
3.3.4.3 Self assessment

Written Assessment
1. What is memory management
2. How are logical memory addresses different from physical memory addresses
3. What causes internal fragmentation?
4. What is swapping?
5. How is simple paging different from demand paging?
6. Why is sufficient virtual memory necessary in a computer system?
7. What is a page map table?
8. Illustrate how a segment map table is used.
9. How does external fragmentation occur
10. What is a page frame?

Oral Assessment
• Describe how demand paging works

Practical Assessment
• Configure the Virtual memory of the provide PC to one and a half size of the current setting

3.3.4.4 Tools, equipment, supplies, and material


• Computer
• Internet connectivity
• Stationery
• Instruction material

3.3.4.5 References

1. Memory Management Techniques in Operating Systems. Retrieved from


https://www.includehelp.com/operating-systems/memory-management-techniques-in-
operating-system.aspx
2. How to change virtual memory size on Windows 10. Retrieved from
https://www.windowscentral.com/how-change-virtual-memory-size-windows-10

125
3.3.5 Learning Outcome 4: Understand Input and Output Management
3.3.5.1 Learning Activities
Learning Outcome 4: Understand Input and Output Management
Learning Activities Special Instructions

4.1 Input - output management is explained ● Activities may be carried out in


4.2 Disk operations are explained groups or as individual
4.3 Computer clock system is explained
4.4 Virtual Input Output is explained
4.5 Disk selection criteria are outlined
4.6 Verification of disk properties is demonstrated
4.7 Disk storage management operations are demonstrated
4.8 Device management operations are demonstrated

3.3.5.2 Information sheet No 3/LO4: Understand Input and output management

Introduction
This learning outcome covers explaining input - output management, explaining disk operations,
explaining the computer clock system, explaining virtual input and output, outlining disk selection
criteria, demonstrating verification of disk properties demonstrating disk storage management
operations and demonstrating device management operations.

Input – Output Management Service


• The controlling of various devices that are connected to the computer is a key concern of
operating-system designers. This is because I/O devices vary so widely in their functionality
and speed (for example a mouse, a hard disk and a CD-ROM), varied methods are required
for controlling them.
• These methods form the I/O sub-system of the kernel of OS that separates the rest of the
kernel from the complications of managing I/O devices.

Input-Output Hardware
One of the important jobs of an Operating System is to manage various I/O devices including
mouse, keyboards, touch pad, disk drives, display adapters, USB devices, Bit-mapped screen,
LED, Analog-to-digital converter, On/off switch, network connections, audio I/O, printers etc.

An I/O system is required to take an application I/O request and send it to the physical device, then
take whatever response comes back from the device and send it to the application. I/O devices can
be divided into two categories −
• Block devices − A block device is one with which the driver communicates by sending
entire blocks of data. For example, Hard disks, USB cameras, Disk-On-Key etc.
• Character devices − A character device is one with which the driver communicates by
sending and receiving single characters (bytes, octets). For example, serial ports, parallel
ports, sounds cards etc.
126
Device Controllers
• Device drivers are software modules that can be plugged into an OS to handle a particular
device. Operating System takes help from device drivers to handle all I/O devices.

• The Device Controller works like an interface between a device and a device driver. I/O
units (Keyboard, mouse, printer, etc.) typically consist of a mechanical component and an
electronic component where electronic component is called the device controller.

• There is always a device controller and a device driver for each device to communicate
with the Operating Systems. A device controller may be able to handle multiple devices.
As an interface its main task is to convert serial bit stream to block of bytes, perform error
correction as necessary.

Figure 46:Device Controllers

Synchronous vs. asynchronous I/O


• Synchronous I/O − In this scheme CPU execution waits while I/O proceeds
• Asynchronous I/O − I/O proceeds concurrently with CPU execution

Communication to I/O Devices


The CPU must have a way to pass information to and from an I/O device. There are three
approaches available to communicate with the CPU and Device.
• Special Instruction I/O
• Memory-mapped I/O
• Direct memory access (DMA)

Special Instruction I/O


This uses CPU instructions that are specifically made for controlling I/O devices. These
instructions typically allow data to be sent to an I/O device or read from an I/O device.

127
Memory-mapped I/O
When using memory-mapped I/O, the same address space is shared by memory and I/O devices.
The device is connected directly to certain main memory locations so that I/O device can transfer
block of data to/from memory without going through CPU.

Figure 47:Memory-mapped I/O

While using memory mapped IO, OS allocates buffer in memory and informs I/O device to use
that buffer to send data to the CPU. I/O device operates asynchronously with CPU, interrupts CPU
when finished.

Direct Memory Access (DMA)


• Slow devices like keyboards will generate an interrupt to the main CPU after each byte is
transferred.
• If a fast device such as a disk generated an interrupt for each byte, the operating system
would spend most of its time handling these interrupts. So a typical computer uses direct
memory access (DMA) hardware to reduce this overhead.
• Direct Memory Access (DMA) means CPU grants I/O module authority to read from or
write to memory without involvement.
• DMA module itself controls exchange of data between main memory and the I/O device.
CPU is only involved at the beginning and end of the transfer and interrupted only after
entire block has been transferred.
• Direct Memory Access needs a special hardware called DMA controller (DMAC) that
manages the data transfers and arbitrates access to the system bus.

Polling vs. Interrupts I/O


• A computer must have a way of detecting the arrival of any type of input.

128
• There are two ways that this can happen, known as polling and interrupts. Both of these
techniques allow the processor to deal with events that can happen at any time and that are
not related to the process it is currently running.

Polling I/O
Polling is the simplest way for an I/O device to communicate with the processor. The process of
periodically checking status of the device to see if it is time for the next I/O operation, is called
polling. The I/O device simply puts the information in a Status register, and the processor must
come and get the information.

Interrupts I/O
• An alternative scheme for dealing with I/O is the interrupt-driven method. An interrupt is a
signal to the microprocessor from a device that requires attention.
• A device controller puts an interrupt signal on the bus when it needs CPU’s attention when
CPU receives an interrupt, it saves its current state and invokes the appropriate interrupt
handler using the interrupt vector (addresses of OS routines to handle various events).
• When the interrupting device has been dealt with, the CPU continues with its original task
as if it had never been interrupted.

I/O Software
I/O software is often organized in the following layers −
• User Level Libraries − this provides simple interface to the user program to perform input
and output. For example, stdio is a library provided by C and C++ programming
languages.
• Kernel Level Modules − this provides device driver to interact with the device controller
and device independent I/O modules used by the device drivers.
• Hardware − this layer includes actual hardware and hardware controller which interact
with the device drivers and makes hardware alive.

A key concept in the design of I/O software is that it should be device independent where it should
be possible to write programs that can access any I/O device without having to specify the device
in advance. For example, a program that reads a file as input should be able to read a file on a hard
disk, or on a CD-ROM, without having to modify the program for each different device.

Device Drivers
Device drivers are software modules that can be plugged into an OS to handle a particular device.
Operating System takes help from device drivers to handle all I/O devices. Device drivers
encapsulate device-dependent code and implement a standard interface in such a way that code
contains device-specific register reads/writes.

Device driver, is generally written by the device's manufacturer and delivered along with the device
on a CD-ROM.

129
A device driver performs the following jobs −
• To accept request from the device independent software above to it.
• Interact with the device controller to take and give I/O and perform required error
handling
• Making sure that the request is executed successfully

How a device driver handles a request is as follows: Suppose a request comes to read a block N.
If the driver is idle at the time a request arrives, it starts carrying out the request immediately.
Otherwise, if the driver is already busy with some other request, it places the new request in the
queue of pending requests.

Interrupt handlers
• An interrupt handler, also known as an interrupt service routine or ISR, is a piece of
software or more specifically a callback function in an operating system or more
specifically in a device driver, whose execution is triggered by the reception of an
interrupt.
• When the interrupt happens, the interrupt procedure does whatever it has to in order to
handle the interrupt, updates data structures and wakes up process that was waiting for an
interrupt to happen.

Device-Independent I/O Software


• The basic function of the device-independent software is to perform the I/O functions that
are common to all devices and to provide a uniform interface to the user-level software.

Following is a list of functions of device-independent I/O Software −


• Uniform interfacing for device drivers
• Device naming - Mnemonic names mapped to Major and Minor device numbers
• Device protection
• Providing a device-independent block size
• Buffering because data coming off a device cannot be stored in final destination.
• Storage allocation on block devices
• Allocation and releasing dedicated devices
• Error Reporting

User-Space I/O Software


• These are the libraries which provide richer and simplified interface to access the
functionality of the kernel or ultimately interactive with the device drivers.
• I/O Libraries (e.g., stdio) are in user-space to provide an interface to the OS resident
device-independent I/O SW. For example putchar(), getchar(), printf() and scanf() are
example of user level I/O library stdio available in C programming.

Kernel I/O Subsystem


130
Kernel I/O Subsystem is responsible to provide many services related to I/O. Following are some
of the services provided.
• Scheduling − Kernel schedules a set of I/O requests to determine a good order in which to
execute them.
• Buffering − Kernel I/O Subsystem maintains a memory area known as buffer that stores
data while they are transferred between two devices or between a device with an
application operation. Buffering is done to cope with a speed mismatch between the
producer and consumer of a data stream or to adapt between devices that have different
data transfer sizes.
• Caching − Kernel maintains cache memory which is region of fast memory that holds
copies of data. Access to the cached copy is more efficient than access to the original.
• Spooling and Device Reservation − A spool is a buffer that holds output for a device, such
as a printer, that cannot accept interleaved data streams. The spooling system copies the
queued spool files to the printer one at a time. In some operating systems, spooling is
managed by a system daemon process. In other operating systems, it is handled by an in
kernel thread.
• Error Handling − an operating system that uses protected memory can guard against many
kinds of hardware and application errors.

Disk I/O Operations


• As we know, a process needs two type of time, CPU time and IO time. For I/O, it requests
the Operating system to access the disk.
• However, the operating system must be fair enough to satisfy each request and at the same
time, operating system must maintain the efficiency and speed of process execution.

• The technique that operating system uses to determine the request which is to be satisfied
next is called disk scheduling.
• When the disk drive is operating, the disk is rotating at constant speed. To read or write the
head must be positioned at the desired track and at the beginning of the desired sector on
that track
• Track selection involves moving the head in a movable-head system or electronically
selecting one head on a fixed-head system
• On a movable-head system the time it takes to position the head at the track is known as
seek time
• The time it takes for the beginning of the sector to reach the head is known as rotational
delay
• The sum of the seek time and the rotational delay equals the access time
• Disk Response Time- It is the average of time spent by each request waiting for the IO
operation.

Purpose of Disk Scheduling


The main purpose of disk scheduling algorithm is to select a disk request from the queue of IO
requests and decide the schedule when this request will be processed.
131
Goal of Disk Scheduling Algorithm
o Fairness
o High throughout
o Minimal traveling head time

Disk Scheduling Algorithms


o FCFS scheduling algorithm
o SSTF (shortest seek time first) algorithm
o SCAN scheduling
o C-SCAN scheduling
o LOOK Scheduling
o C-LOOK scheduling

Computer clock system in I/O


Three types of time services are commonly needed in modern systems:
• Get the current time of day.
• Get the elapsed time (system or wall clock) since a previous event.
• Set a timer to trigger event X at time T.

Unfortunately time operations are not standard across all systems.

A programmable interrupt timer, PIT can be used to trigger operations and to measure elapsed time.
It can be set to trigger an interrupt at a specific future time, or to trigger interrupts periodically on a
regular basis.

The scheduler uses a PIT to trigger interrupts for ending time slices. The disk system for example
may use a PIT to schedule periodic maintenance cleanup, such as flushing buffers to disk.

Virtual Input Output


I/O virtualization (IOV) is technology that uses software to abstract upper-layer protocols from
physical connections

This technique takes a single physical component and presents it to devices as multiple
components. Because it separates logical from physical resources, IOV is considered an enabling
data center technology that aggregates IT infrastructure as a shared pool, including computing,
networking and storage.

Key Disk selection criteria

Choose the correct interface.

132
Choose a PATA drive if you are repairing or upgrading an older system that lacks SATA
interfaces. Choose an SATA drive if you are repairing or upgrading a system that has SATA
interfaces.

Buy the right capacity drive.


Very large drives often cost more per gigabyte than midsize drives, and the largest drives may have
slower mechanisms than midsize drives. In general, decide what performance level you need and
are willing to pay for, and then buy a drive that meets those performance requirements, choosing
the model based on its cost per gigabyte

Get a model with large cache if it doesn't cost much more.


Disk drives use cache (or buffer) memory to increase performance. Generally, the larger the cache,
the faster the performance.

Pay attention to power consumption and noise level.


Similar drives can differ significantly in power consumption and noise level. A drive that
consumes more power also produces more heat, which contributes indirectly to overall system
noise level because the system exhaust fans must work harder.

Length of Warranty - warranties provide consumers with a guarantee that the hard disk they
purchase will be repaired or replaced if a defect should crop up that is determined to be the fault of
the manufacturer.

Verifying Disk properties in Windows


If you'd like to view detailed information about your hard disk drives, solid-state drives, or external
storage devices attached to your computer, you can access System Information utility.

To open the System Information utility in Windows 10:


1. Press the Windows key, type System Information, and press Enter.

Or, you can use the Run box to open the System Information utility.
• Press Win + R (hold down the Windows key and press R).
• In the Run box, type msinfo32.
• Press Enter or click OK.

133
6. In the System Information window that opens, in the left window pane, you'll see a list of
hardware categories. Expand Components, then Storage. Then, choose Drives, Disks, or any
category you'd like to view.

Disk Storage Management in Windows


Disk Management is an extension of the Microsoft Management Console that allows full
management of the disk-based hardware recognized by Windows.

Disk Management is used to manage the drives installed in a computer—like hard disk drives
(internal and external), optical disk drives, and flash drives. It can be used to partition drives, format
drives, assign drive letters, and much more.

Disk Management Availability

134
Disk Management is available in most versions of Microsoft Windows including Windows 10,
Windows 8, Windows 7, Windows Vista, Windows XP, and Windows 2000.

Note: Even though Disk Management is available in multiple Windows operating systems, some
small differences in the utility do exist from one Windows version to the next.

How to Open Disk Management


The most common way to access Disk Management is via the Computer Management utility.

How to Open Disk Management

Figure 48: Windows Disk Manager

Disk Management can also be started by executing diskmgmt.msc via the Command Prompt or
another command-line interface in Windows.

How to Use Disk Management


Disk Management has two main sections—a top and a bottom:

The top section of Disk Management contains a list of all the partitions, formatted or not, that
Windows recognizes.

The bottom section of Disk Management contains a graphical representation of the physical drives
installed in the computer.

N/B: The panes and menus you see in Disk Management are customizable, so if you've ever
changed the settings, the above might not be exactly how the program looks to you. For example,
you can change the top pane to be the graphical representation and disable the bottom pane entirely.
Use the View menu to change where the panes are displayed in Disk Management.

135
Performing certain actions on the drives or partitions make them available or unavailable to
Windows and configure them to be used by Windows in certain ways.

Here are some common things that you can do in Disk Management:
i) Partitioning a volume
ii) Formattinga volume
iii) Shrinking volume

Partitioning a volume
The first thing to do after installing a hard drive is to partition it. You have to partition a hard drive,
and then format it, before you can use it to store data.

To partition a hard drive in Windows means to section off a part of it and make that part available
to the operating system. Most of the time, the "part" of the hard drive is the entire usable space, but
creating multiple partitions on a hard drive is also possible so that you can store backup files in one
partition, movies in another, etc.

Don't worry if this sounds like more than you thought — partitioning a hard drive in Windows isn't
hard and usually only takes a few minutes to do.

How to Partition a Hard Drive in Windows


N/B: Manually partitioning (as well as formatting) a hard drive is not necessary if your end goal is
to install Windows onto the drive. Both of those processes are included as part of the installation
procedure, meaning you don't need to prepare the drive yourself.

1. Open Disk Management, the tool included in all versions of Windows that lets you partition
drives, among a number of other things.

How to Open Disk Management

136
Note: In Windows 10 and Windows 8/8.1, the Power User Menu is the easiest way to start Disk
Management. You can also start Disk Management via command-line in any version of Windows
but the Computer Management method is probably best for most people.

2. When Disk Management opens, you should see an Initialize Disk window with the message
"You must initialize a disk before Logical Disk Manager can access it."
Initialize Disk window

Don't worry if this window doesn't appear. There are legitimate reasons you may not see it. Skip
on to Step 4 if you don't see this.

3. On this screen, you're asked to choose a partition style for the new hard drive. Choose GPT if the
new hard drive you installed is 2 TB or larger. Choose MBR if it's smaller than 2 TB. Select OK
after making your selection.

4. Locate the hard drive you want to partition from the drive map at the bottom of the Disk
Management window. You might need to maximize the Disk Management or Computer
Management window to see all the drives on the bottom. An unpartitioned drive will not show up in
the drive list at the top of the window.

If the hard drive is new, it will probably be on a dedicated row labeled Disk 1 (or 2, etc.) and will
say Unallocated. If the space you want to partition is part of an existing drive, you'll see
Unallocated next to existing partitions on that drive.

If you don't see the drive you want to partition, you may have installed it incorrectly. Turn
off your computer and double-check that the hard drive is properly installed.

5. Once you've found the space you want to partition, tap-and-hold or right-click anywhere on it,
and choose New Simple Volume.

137
New Partition

6. Choose Next > on the New Simple Volume Wizard window that appeared.

New Simple Volume Wizard window

7. Choose Next > on the Specify Volume Size step to confirm the size of the drive you're creating.

Specify Volume Size

138
The default size that you see in the Simple volume size is in MB: field should equal the amount
shown in the Maximum disk space in MB: field. This means that you're creating a partition that
equals the total available space on the physical hard drive.

You're welcome to create multiple partitions that will eventually become multiple, independent
drives in Windows. To do so, calculate how many and how large you want those drives to be and
repeat these steps to create those partitions. For example, if the drive is 61437 MB and you want to
partitions, specify an initial size of 30718 to partition only half the drive, and then repeat the
partitioning again for the rest of the unallocated space.

Select Next > on the Assign Drive Letter or Path step, assuming the default drive letter you see is
OK with you

Windows automatically assigns the first available drive letter, skipping A & B, which on most
computers will be D or E. You're welcome to set the Assign the following drive letter option to
anything that's available.

You're also welcome to change the letter assigned to this hard drive later on if you want. See How
to Change Drive Letters in Windows for help doing that.

8. Choose Do not format this volume on the Format Partition step, and then select Next
9. Verify your choices on the Completing the New Simple Volume Wizard screen.
Volume Type: Simple Volume
Disk selected: Disk 1
Volume size: 61437 MB
Drive letter or path: F:
File system: None
Allocation unit size: Default

NOTE: Because your computer and hard drive are unlikely exactly like above, expect your Disk
selected, Volume size, and Drive letter or path values to be different than what you see here. File
system: None just means that you've decided not to also format the drive right now.

139
10. Choose Finish and Windows will partition the drive, a process that will only take a few seconds
on most computers.

You might notice that your cursor is busy during this time. Once you see the new drive letter (F: in
our example) appear in the listing at the top of Disk Management, then you know the partitioning
process is complete.

11. Next, Windows will try to open the new drive automatically. However, since it's not yet
formatted and can't be used, you'll see this message instead: "You need to format the disk in drive
F: before you can use it. Do you want to format it?"

12. Tap or click Cancel for now.

Formatting a volume
You need to format a hard drive if you plan on using it in Windows. To format a hard drive means
to erase any information on the drive and to set up a file system so your operating system can read
data from, and write data to, the drive.

All operating systems offer this capability and Windows makes it easy. Before formatting a drive, it
must be partitioned first.

The time it takes to format a hard drive in Windows depends almost entirely on the drive's size, but
your computer's overall speed plays a part, too.

How to Format a Hard Drive in Windows


Step 1. Open Disk Management, the hard drive manager included with all versions of Windows.

Open Disk Management

2. After Disk Management opens, which might take several seconds, look for the drive you want to
format from the list at the top. There's a lot of information in Disk Management, so if you can't see
everything, maximize the window.

Drive to format
140
3. Look for the amount of storage on the drive as well as the drive name. For example, if it says
Music for the drive name and it has 2 GB of hard drive space, then you've likely selected a small
flash drive full of music.

Feel free to open the drive to make sure that it's what you want to format if it makes you confident
that you're going to format the right device.

If you don't see the drive listed on the top or an Initialize Disk windows appears, it probably means
that the hard drive is new and has not yet been partitioned.

Now that you've found the drive you want to format, right-click it and choose Format to

Existing Drive: If you're formatting a drive that you've been using and that has data on it, double-
check in Explorer that the drive letter you're choosing here in Disk Management is the same as the
one you see in Explorer that has the information on it that you want to erase. Once formatted, the
existing data on the disk are probably unrecoverable for most people.

141
New Drive: If you're formatting a new drive, a great way to tell that it's the right one is to look at
the File System column in the top part of Disk Management. Your existing drives will show file
systems of NTFS or FAT32 but a new, unformatted drive will show RAW instead.

You cannot format your C drive, or whatever drive Windows is installed on, from within
Windows. In fact, the Format option isn't even enabled for the drive with Windows on it.

4. The first of several formatting details which covered over the next several steps is the volume
label, which essentially a name is given to the hard drive.

In the Volume label textbox, enter whatever name you'd like to give to the drive.

If the drive had a previous name and that makes sense for you, by all means, keep it. Drive
letters are assigned during the Windows partitioning process but can easily be changed after the
format is complete.

5. Next up is the file system choice. In the File system textbox, choose NTFS.
NTFS

NTFS is the most recent file system available and is almost always the best choice.
6. In the Allocation unit size textbox, choose Default. The best allocation size based on the size of
the hard drive will be chosen.

It's not at all common to set a custom allocation unit size when formatting a hard drive in Windows.
7. Next is the Perform a quick format checkbox. Windows will check this box by default,
suggesting that you do a "quick format" but we recommend that you uncheck this box so that a
"standard format" is performed.

142
In a standard format, each individual "part" of the hard drive, called a sector, is checked for errors
and overwritten with a zero — a sometimes painfully slow process. This procedure ensures that the
hard drive is physically working as expected, that each sector is a reliable place to store data, and
that existing data is unrecoverable.

In a quick format, this bad sector search and basic data sanitization is skipped entirely and
Windows assumes that the hard drive is free of errors. A quick format is very fast.

The final format option is the Enable file and folder compression setting that is unchecked by
default, which we recommend sticking with.

The file and folder compression feature allows you to choose files or folders to be compressed and
decompressed on the fly, potentially offering considerable savings on hard drive space. The
downside here is that performance can be equally affected, making your day-to-day Windows use
much slower than it would be without compression enabled.

File and folder compression has little use in today's world of very large and very inexpensive hard
drives. In all but the rarest occasions, a modern computer with a large hard drive is better off
protecting all the processing power it can and skipping on the hard drive space savings.

7. Review the settings you've made in the last several steps and then click OK.

As a reminder, here's what you should see:

• Volume label: [label of your choosing]


• File system: NTFS
• Allocation unit size: Default
• Perform a quick format: unchecked
• Enable file and folder compression: unchecked

8. Windows is usually pretty good about warning you before you might do something damaging,
and a hard drive format is no exception.

Click OK to the warning message about formatting the drive.

Warning message

143
Note: Just as the warning says, all the information on this drive will be erased if you click OK. You
can't cancel the format process halfway through and expect to have half of your data back. As soon
as this starts, there's no going back.

9. The hard drive format has begun!


You can check the progress by watching the Formatting: xx% indicator under the Status column in
the top part of Disk Management or in the graphical representation of your hard drive in the bottom
section.

Format progress

If you chose a quick format, your hard drive should only take several seconds to format. If you
chose the standard format, which we suggested, the time it takes the drive to format will depend

144
almost completely on the size of the drive. A small drive will take a small amount of time to format
and a very large drive will take a very long time to format.

Your hard drive's speed, as well as your overall computer's speed, play some part but the size is the
biggest variable.

In the next step, we'll look at whether the format completed as planned.
After the format percentage indicator reaches 100%, wait a few seconds and then check again under
Status and make sure it's listed as Healthy like your other drives.

You may notice that now that the format is complete, the volume label has changed to what you set
it as (New Drive in our case) and the % Free is listed at 100%. There's a little overhead involved so
don't worry if your drive isn't completely empty. That's it!

Your hard drive has been formatted and it's ready for use in Windows. You can use the new drive
however you want — back up files, store music, and videos, etc.

Note: Formatting Deletes Data — but Doesn't Always Erase It


When you format a drive in Windows, data may or may not truly be erased. Depending on your
version of Windows, and the type of format, it's possible the data is still there, hidden from
Windows and other operating systems but still accessible in certain situations.

If the hard drive you're reformatting won't ever need to be used again, you can skip the format and
the wipe, and physically or magnetically destroy it instead.

Sharing a volume
Shrinking volume refers to the task of decreasing the size of a partition, which helps to organize
disk space in accordance with specific needs. When you have a large partition that has much free
space to spare, it may make sense to spare free space from the volume by shrinking it, for instance
you can either create a new partition on unallocated space or add it to other partitions.

As we all know, a disk should be partitioned before we can use the space on the disk to store data.
There can be multiple volumes on the disk and each works like distinct area, thus you can separate
operating systems from personal data and manage data orderly.

Why shrink a volume?


Changing partition size is a useful practice if you want to make best of disk space on your
computer. For instance, there is a 2TB hard drive on your computer and the disk is divided into two
partitions, a 500GB system partition where Windows is installed and a 1.4TB partition for your
music, photos, games, working documents, learning material, etc.

Thus, this disk is not properly partitioned. There might be too much free space in C drive (system
partition), and the other partition contains too many file types. In this case, you can shrink system

145
volume to a suitable size such as 100GB, and you can get 400GB free space which can be used to
create a new partition to store data.

For the large partition, you can split it, after which you can store working files on one partition,
games on a different partition. Apart from organizing data effective, some user shrinks partition for
the purpose of dual boot computer. There is not enough free space on the disk to create a new
partition for new operating system, and you can shrink a large partition to get free space.

Tools to shrink partition


Changing partition size is one the basic operations that should be mastered by computer users for
the sake of taking full advantage of disk space and rationally managing data.

i) Disk Management: Disk Management is the Windows internal tool and it provides basic function
to manage disk and partitions.

Users can extend partition by adding the adjacent free space, shrink partition, create new partition,
etc. But it cannot deal with all partition resizing tasks, for example, unallocated space is not on the
right side or not adjacent to the partition. If you want to do extra operations, you need to use third-
party disk partition software.

ii) Disk partition software: partition management software enables you to create, delete, format,
shrink, extend, split, expand or resize partitions on your hard drive or other storage devices.

Example: DiskGenius Free includes more features than Disk Management and similar third-party
software. Apart from regular functions on disk partitions, it also can wipe hard drive, erase
partition, permanently delete data, image disk/partition, clone partition /disk, convert GPT/MBR
disk, convert virtual disk format, edit hex data, check and repair bad sectors, check partition table
errors, manage virtual disks, etc. Besides, it supports file recovery and partition from various
storage devices.

iii) DiskPart commands: DiskPart commands help to manage disks, partitions, volumes or virtual
disk and you can use it shrink partition if you know how to use it. The shrink command reduces the
size of selected volume by the specified amount. Similar to Disk Management, it is able to get free
disk space from the unused space at the end of selected volume.

Shrink a basic volume in Disk Management


1. Open Disk Management.
2. Right-click on the partition you want to reduce its size and choose Shrink Volume, as below.

Then Disk Management starts to query the volume for available space to shrink, which may take a
couple of seconds, then wait with patience. It'll be better if the partition was properly defragmented
in advance.

146
When the calculation finishes, a window pops up. In Disk Management, you can view all disks and
partitions on your computer, locate the one you want to spare free space. In this case, we are going
to shrink the 120GB New Volume (D :) which is located on basic disk 1.

If Shrink Volume option is grayed out, then it is not supported for the partition, for example the
FAT32 partition of USB flash drive. In this case, you need to use a tool such as DiskGenius to
resize it.

Shrink Volume

3. Specify the disk amount you want to reduce from the partition. Enter the exact disk space in MB
and click Shrink button.

Note: you cannot shrink a partition beyond the point where any unmovable files are located.

Shrink a basic volume

147
Disk Management completes the process quickly and the you'll be back at the original interface and
see the shrunk partition and unallocated disk space on the drive. Then you can create a new
partition on it.

Shrink limitations on Disk Management:


Disk Management cannot deal with all issues about partition shrink, and here are some limitations.

This option is available for primary partitions and logical drive or volumes formatted in NTFS file
system and it grays out on FAT32 or FAT16 or any other types partitions.

The shrinking process will fail if there are too many bad clusters on the volume.
If the partition you want to shrink does not have a file system such as RAW drive and contains data
like database file, shrining the drive may destroy the data.

When you try to shrink a system volume, you may not be able to reduce the partition size beyond
the point where unmovable files are stored, like paging file, hibernation file, shadow copy storage
area, etc.

Disk Optimization and Defragmentation


There are two types of optimization; hardware and software optimization

Hardware Optimization
From a hardware perspective there are two things we can do to optimize the performance of our
storage system. The first thing we can do is to upgrade to the fasted hard disk possible.

Hard drives come in different rotational speeds. Currently the slowest drives run at about 5400
revolutions per minute (RPM). The rotation speed dictates how fast data can be written to, or read
from the hard disk drive. The faster the drive spins, the faster it can read data and the faster it can

148
store data. As a bare minimum we should get a 7200 RPM drive. More RPMs also mean more
money for the drive.

The second thing we can do is to upgrade our disk interface. If we have to stick with IDE then we
should ensure that our motherboard supports the ATA133 standard, which transfers data at roughly
133 megabits per second. Also, disks have to support ATA33 standard as well. Upgrading to a
faster disk interface will dramatically improve the throughput of data to and from our hard disk
drive. Because of that we should move away from the older ATA/IDE interface and upgrade to a
serial ATA disk interface (SATA). By doing this we can upgrade speed to 150 megabytes for
SATA 1, 300 MB for SATA 2, or 600 MB for SATA 3.

Software Optimization
Disk Clean-up
When talking about software optimization one of the key things that we can do is keep our disk
clean. That means that we should get rid of the files that we don’t need. Mostly empty drive is
faster than a full one. A drive that is mostly full is a bit slower because the hard disk interface has to
go all over the hard drive to find pieces of a file or trying to find an empty space in which to save a
file.

To accomplish this, one thing we can do is to run Disk Cleanup utility. To run disk clean-up, go to
the properties of the drive and in the General tab click on the Disk Clean-up button. Disk
Clean-up helps us to dispose of files that can be safely removed from the disk. Those include
emptying the Recycle Bin, deleting temporary files such as those used by Internet Explorer
(temporary Internet files), application installation files, installation log files, offline web pages,
hibernation files, Windows error reports, and also compressing old files. We can also run Dick
Clean-up in CMD by typing cleanmgr.

Regular users can also run Disk Clean-up wizard, but they will be only able to delete user specific
files, and not system files.

Another thing we can do is to remove unused Windows components. When Windows is installed
by default a certain set of Windows components are included in the installation. To do that we can
go into Control Panel > Add/remove programs > Windows Components and deselect different
components that we never use. Getting rid of certain things that we don’t use frees up space on the
hard disk drive. When our hard disk drive has more free space the disk interface can read
information faster and it can write information faster.

Fragmentation
Another thing we can do is to defragment our disk drive.

When hard disk controller writes data to the disk it scatters parts of the same file over different
areas of the disk. This is called fragmentation, and it gets worse as time goes along. After we first

149
install an operating system and start installing applications, disk isn’t fragmented very badly, since
new files and folders are created on available free space in contiguous blocks.

This is the most optimized way to store files on our disk. The fragmentation occurs over time, as we
delete and then add new files. That’s because as the free space reduces, the amount of contiguous
block is also reduced. Pretty soon fragments are stored all over the hard disk drive. In other words,
different parts of the same file are stored on different sectors of the hard drive, which leads to
suboptimal performance.

On the picture below we can see how files are scattered on the disk. In this example the disk should
be defragmented. White area indicates free space, while other lines indicates data on the drive.

Figure 49:Disk Fragmentation

When we try to open fragmented file, in order for system to display that file, the disk interface has
to find all the chunks of the file on the disk, then reassemble them and load it into memory so that
the application can use it. The more fragmented a file is, the longer it takes to read the information
from the disk.

The same thing is when we’re writing information. If we have empty chunks of hard disk space
which are scattered all over the disk, and we’ve got a large file that needs to be written, that file will
get fragmented as it is written to the disk, which will slow things down. In order to fix this we need
to defragment the hard disk drive. When we defragment the drive, the system will take all the
chunks of the same file and put them in contiguous blocks. They will still be separate chunks, but
they’ll be next to each other.

So, the defragmentation is the process of moving parts of a file to contiguous sectors on the hard
disk drive, to increase the speed of access and retrieval. We can do this using the defragmentation
utility that comes with Windows.

To defragment disks in Windows, go to the properties of the drive, open the Tools tab and click on
the Defragment Now button. Before the defragmentation we will have to analyze the disk first. The
more information on the drive, the more time it will take to defragment the drive. To run Disk
Defragmenter in CMD we can type in the Defrag command.

We should configure our computer to run defragmentation on a schedule. We can use our computer
during the defragmentation process, but it is recommended not to since we can actually create
additional fragmentation as we work. Remember that we can’t defragment network drives, and that
only one defragmentation process can run at the time.

150
To determine if our disk needs defragmentation, we can use the Analyze Disk option. We have to
have administrative rights to run defragmentation.

Scan For Errors


Another thing we can do to optimize storage devices is to scan disks for errors. We can use the error
checking utility in Windows to check for file systems errors and bad sectors on our hard drive. We
can choose to automatically try to fix errors.

Error checking tool looks for and fixes two different things. First it looks for lost clusters. A lost
cluster is a series of clusters on the hard disk drive that are not associated with a particular file. Data
is there but it’s unknown as to what file that data belongs to. Error checking tool looks for those and
tries to repair them. Usually it can repair them, but sometimes it can’t. If we’re in a situation where
we can’t repair lost clusters that usually means we’ve got some serious disk errors and we’re going
to be losing some data.

The second thing that errors checking utility checks for are cross linked files. A cross linked file
occurs when two files try to claim the same cluster. Both of files claim that particular cluster is a
part of itself. Error checking tool will look for cross linked filed and fix those. Orphaned files are
files that exist on the hard drive but which are not associated with a directory in the index.

Normally Check Disk can re-associate the file with the correct directory. Abad sector is a portion of
the hard disk that cannot be used. Bad sectors are marked so that they are no longer used. Any used
bad sectors are redirected to another sector. The NTFS file system automatically detects bad sectors
as the system saves and reads files.

We can run Check Disk by typing Chkdsk command at a command prompt. We can also use
Chkdsk command with the /f switch to automatically fix errors without scanning for bad sectors.
Also, we can use the /r switch to scan and fix bad sectors and other errors.

Check Disk replaces the ScanDisk utility that was available in Windows 9x/Me, so Check Disk is
sometimes referred to as Scan Disk.

We should perform defragmentation and disk checking on regular basis and do them frequently.
How frequently depends on how heavily the system is used. If we have a heavily used system we
should run error checking scan, disk clean up and disk defragmentation about once a week, maybe
even more frequently.

If it’s a system that doesn’t get used much then we could probably get away with doing this once a
month. To check for disk errors in Windows, go to the properties of the drive, open the Tools tab
and click on the Check Now button.

Device Management in Windows

151
Device Manager is a Windows utility that allows you to update and reinstall drivers for individual
devices (e.g. your video card, sound card or network card).

How to identify (some) problem drivers using Windows Device Manager


Windows Device Manager shows you which devices have corrupt drivers. It may also show you
which devices have outdated drivers.

IMPORTANT: Windows Device Manager doesn’t always detect outdated drivers. So you
can’t assume all your drivers are up to date

To identify corrupt drivers and maybe some outdated drivers:


1. On your keyboard, press the Windows logo key and R at the same time to invoke the run box.
2. Type devmgmt.msc and click OK.

(There are other ways to open Device Manager; it changes depending on your version of Windows.
But the above method works for all versions of Windows)
3. Select a category and expand it to see the devices in that category.
4. If you see a yellow triangle or question mark next to a device, that means Windows has detected
that it has an outdated or corrupt driver. For example:

152
Figure 50: Windows Device Manager

When you see this yellow mark, the device has a corrupt or outdated driver. You can try to update
or reinstall the driver as described below.

How to update or reinstall drivers using Windows Device Manager


To update a device’s driver in Windows Device Manager:
1. On your keyboard, press the Windows logo key and R at the same time to invoke the run box.
2. Type devmgmt.msc and click OK.

3. Select a category and expand it to see the devices in that category.


4. Right-click the device whose driver you’d like to update.
5. Select Update Driver.

153
6. Select Search automatically for updated driver software.

To reinstall a device’s driver in Windows Device Manager:


1. On your keyboard, press the Windows logo key and R at the same time to invoke the run box.
2. Type devmgmt.msc and click OK.

154
3. Select a category and expand it to see the devices in that category. Right-click the device whose
driver you’d like to reinstall.
4. Select Uninstall device.

5. Restart your PC.


6. Windows will attempt to reinstall the driver.

What Windows Device Manager DOESN’T do


Windows Device Manager doesn’t always detect outdated drivers. That’s because it categorizes
driver updates as either ‘critical’, ‘automatic’ or ‘optional’, and it doesn’t usually concern itself
with the ‘optional’ ones.
So long as you have the necessary ‘critical’ and ‘automatic’ updates, Windows is ok. It won’t, for
example, install a new ‘optional’ update, if it already has an old ‘critical’ update installed.

155
But all driver updates are important, even when Windows calls them ‘optional’. If they weren’t, the
hardware manufacturers wouldn’t go to all the trouble of coding and releasing them.

Sometimes these ‘optional’ updates include just a new, nice-to-have feature, and you can arguably
do without that. But sometimes it’s an important bug fix – perhaps the old driver is causing your
device to stop working or your computer to crash. Windows often categorizes these updates as
‘Critical’, but definitely not always.
Other times, it’s not Device Manager’s fault at all. It’s just that the device manufacturer has failed
to include the drivers you need in the latest Windows Update.

What to do when Windows Device Manager won’t update a device driver


If you’re unable to update a device driver in Windows Device Manager, Microsoft says:
“If Windows doesn’t find a new driver, you can try looking for one on the device manufacturer’s
website and follow their instructions.”

To do this, you’ll need to know the brand and model of the device, as well as your exact operating
system and whether it’s 32 or 64 bit. Then you have to find the manufacturer’s driver download
page, find the correct driver, and check that it’s newer than the one you already have installed.

Conclusion
At the end of this learning outcome, the trainee should be able to explain input - output
management, explain disk operations, explain the computer clock system, explain virtual input and
output, outline disk selection criteria, verify disk properties demonstrate disk storage management
operations and demonstrate device management operations.

Further reading

1. https://www.drivereasy.com/knowledge/a-common-and-easy-way-to-access-device-
manager-in-windows/
2. https://docs.microsoft.com/en-us/windows-server/storage/disk-management/overview-of-
disk-management
3.2.5.4 Self assessment
Written Assessment

1. What is the role of device drivers in I/O?


2. How do block I/O devices work?
3. Why is it necessary to partition a volume?
4. Which I/O software libraries does an operating system use?
5. How does disk defragmentation improve disk performance?
6. How is disk access time determined?

156
Oral Assessment
1. What circumstances would require device drivers to be updated?
2. Which options are available for hardware optimisation?

Practical Assessment
Use appropriate tools to:
• Check for disk errors
• Perform disk cleaning
• Check hard disk properties
• View driver settings

3.3.2.4 Tools, Equipment, Supplies and Materials


• Computer
• Internet
• Stationery
• Stationery
• Instruction material

3.3.2.5 References
1. https://www.javatpoint.com/os-disk-scheduling
2. https://www.tutorialspoint.com/operating_system/os_io_hardware.htm
3. https://www.ifixit.com/Wiki/Choosing_a_Hard_Drive

157
3.3.6 Learning Outcome 5. Understand File Management and local policy settings
3.3.6.1 Learning Activities
Learning Outcome 5: Understand File Management and local policy settings
Learning Activities Special Instructions

5.1 File management is explained. Activities may be carried out in groups


5.2 File access methods are explained. or as individual
5.3 File allocation techniques are explained.
5.4 File protection and security are explained.
5.5 File and directory operations are demonstrated
5.6 Local policy settings are demonstrated

3.3.6.2 Information sheet No 3/LO5: Understand File management and local policy settings

Introduction
This learning outcome covers explaining file management, file access methods, file allocation
techniques, file protection and security and demonstrating file and directory operations and local
policy settings

File Management
The file management system is a software which is used to create, delete, modify and control
access and save files.

Responsibilities of File Management System


The responsibilities of File Management System are as follows −
Operation
This provides user to work with or manipulate the files. Manipulation includes open, close, save,
copy, delete, move, rename, share, etc.

Security
By supporting authorization, it restricts unauthorized user to log into system and access files.
Username and password are required for authorization purpose. It supports file encryption feature
and asks for authorization to access those encrypted files.

Integrity
In support of integrity, file management system will keep track of data manipulations like deletion,
modification, addition of data, etc. If the data gets modified, deleted or added, then those changes
should be reflected in all the files.

Storage
This allocates memory for storing files, deallocates memory of deleted or unused files and
maintains backups.
158
Definitions

File
A file is a named collection of related information that is recorded on secondary storage such as
magnetic disks, magnetic tapes and optical disks. In general, a file is a sequence of bits, bytes,
lines or records whose meaning is defined by the files creator and user.

Files are used to provide a uniform view of data storage by the operating system. All the files are
mapped onto physical devices that are usually nonvolatile so data is safe in the case of system
failure.

File Attributes
The attributes of a file may vary a little on different operating systems. However, the common file
attributes are:
Name
This denotes the symbolic name of the file. The file name is the only attribute that is readable
by humans easily.
Identifier
This denotes the file name for the system. It is usually a number and uniquely identifies a file
in the file system.
Type
If there are different types of files in the system, then the type attribute denotes the type of file.
Location
This points to the device that a particular file is stored on and also the location of the file on
the device.
Size
This attribute defines the size of the file in bytes, words or blocks. It may also specify the
maximum allowed file size.
Protection
The protection attribute contains protection information for the file such as who can read or
write on the file.

File Structure
A File Structure should be according to a required format that the operating system can
understand.
• A file has a certain defined structure according to its type.
• A text file is a sequence of characters organized into lines.
• A source file is a sequence of procedures and functions.
• An object file is a sequence of bytes organized into blocks that are understandable by the
machine.
• When operating system defines different file structures, it also contains the code to support
these file structure. UNIX, MS-DOS support minimum number of file structure.

159
File Access Methods in Operating Systems
File access mechanism refers to the manner in which the records of a file may be accessed. There
are several ways to access files −
• Sequential access
• Direct/Random access
• Indexed sequential access

Sequential access
A sequential access is that in which the records are accessed in some sequence, i.e., the
information in the file is processed in order, one record after the other. This access method is the
most primitive one. Example: Compilers usually access files in this fashion.

Direct/Random access
• Random access file organization provides, accessing the records directly.
• Each record has its own address on the file with by the help of which it can be directly
accessed for reading or writing.
• The records need not be in any sequence within the file and they need not be in adjacent
locations on the storage medium.

Indexed sequential access


• This mechanism is built up on base of sequential access.
• An index is created for each file which contains pointers to various blocks.
• Index is searched sequentially and its pointer is used to access the file directly.

File/Space Allocation Techniques


Files are allocated disk spaces by operating system. Operating systems deploy following three
main ways to allocate disk space to files.
• Contiguous Allocation
• Linked Allocation
• Indexed Allocation

Contiguous Allocation
• Each file occupies a contiguous address space on disk.
• Assigned disk address is in linear order.
• Easy to implement.
• External fragmentation is a major issue with this type of allocation technique.

Linked Allocation
• Each file carries a list of links to disk blocks.
• Directory contains link / pointer to first block of a file.
• No external fragmentation
• Effectively used in sequential access file.

160
• Inefficient in case of direct access file.

Indexed Allocation
• Provides solutions to problems of contiguous and linked allocation.
• An index block is created having all pointers to files.
• Each file has its own index block which stores the addresses of disk space occupied by the
file.
• Directory contains the addresses of index blocks of files.

File Protection and Security


In computer systems, a lot of user’s information is stored, the objective of the operating
system is to keep safe the data of the user from the improper access to the system.
Protection can be provided in number of ways.

For a single laptop system, we might provide protection by locking the computer in a desk
drawer or file cabinet. For multi-user systems, different mechanisms are used for the
protection.

Controlling File Access:


The files which have direct access of the any user have the need of protection. The files
which are not accessible to other users doesn’t require any kind of protection.

The mechanism of the protection provide the facility of the controlled access by just
limiting the types of access to the file. Access can be given or not given to any user
depends on several factors, one of which is the type of access required.

Several different types of operations can be controlled:


• Read –Reading from a file.
• Write – Writing or rewriting the file.
• Execute – Loading the file and after loading the execution process starts.
• Append – Writing the new information to the already existing file, editing must be end
at the end of the existing file.
• Delete –Deleting the file which is of no use and using its space for other data.
• List – List the name and attributes of the file.

Operations like renaming, editing the existing file, copying; these can also be controlled.
There are many protection mechanism. Each of them mechanism have different
advantages and disadvantages and must be appropriate for the intended application.

Access Control
There are different methods used by different users to access any file. The general way of
protection is to associate identity-dependent access with all the files and directories and
161
list called access-control list (ACL) which specify the names of the users and the types of
access associate with each of the user.

The main problem with the access list is their length. If we want to allow everyone to read
a file, we must list all the users with the read access. This technique has two undesirable
consequences:

i) Constructing such a list may be tedious and unrewarding task, especially if we


do not know in advance the list of the users in the system.
ii) Previously, the entry of the any directory is of the fixed size but now it changes
to the variable size which results in the complicates space management.
These problems can be resolved by use of a condensed version of the access list.
To condense the length of the access-control list, many systems recognize three
classification of users in connection with each file:
• Owner –
Owner is the user who has created the file.
• Group –
A group is a set of members who has similar needs and they are sharing the same
file.
• Universe –
In the system, all other users are under the category called universe.

The most common recent approach is to combine access-control lists with the normal
general owner, group, and universe access control scheme. For example: Solaris uses the
three categories of access by default but allows access-control lists to be added to
specific files and directories when more fine-grained access control is desired.

Other Protection Approaches:


The access to any system is also controlled by the password. If the use of password are is
random and it is changed often, this may be result in limit the effective access to a file.

The use of passwords has a few disadvantages:


• The number of passwords are very large so it is difficult to remember the large
passwords.
• If one password is used for all the files, then once it is discovered, all files are
accessible; protection is on all-or-none basis.

File and Directory Operations in Windows

How to Change File Attributes in Windows 10


File attributes are special metadata or properties of files stored in the file system which instruct
computer software to change its behavior.
162
Some of them may be enforced by operating system. For example, the read-only attribute prevents
apps from writing to such files and tells File Explorer to warn the user that the file or folder can be
important.

Windows 10 offers the user a number of methods to change file system attributes for folders and
files. Each attribute can have only one state at a moment: it can be set or disabled. While file
attributes are part of file system metadata, they always considered separate from other metadata
values like file date or permissions.

In Windows 10, you can use File Explorer (both the Ribbon option and the File Properties dialog),
PowerShell, and the command prompt to modify or set file attributes.

Using the File explorer to change file attributes


1. Open File Explorer and go to the folder that contains your files.
2. Select the file whose attributes you want to change.
3. On the Home tab of the Ribbon, click on the Properties button.

Figure 51:Windows File explorer

Sharing through File Explorer in Windows 10


Use File Explorer to share files and folders with specific people, or anyone on the network. You
always have control over what you've shared, and whether other users can look at or edit your files.

Share an item on your network


1. Open File Explorer and find the item you'd like to share.
2. Right-click on the item, then click Give access to > Choose a name or click Specific people.

163
Figure 52: Windows file sharing

3. Click the drop-down to choose someone to share the item with:


• Named user: Choose another user account on this computer.
• Everyone: Share the item with any user on the network
• Create a new user: Set up a new user account on the computer to share the item with.

4. When you've chosen the user or group to share with, click Add.
5. Click Share to make the changes you've selected, then click Done to close.

File permissions

164
File permissions control what can happen to items you've shared. Usually, they'll be either 'Read' or
'Read/Write'.

By default, Windows 10 shares files and folders in 'Read' mode. Users will be able to open them,
but they can't save any changes to the original file.

To let others change a file, or add items to a shared folder, you'll have to give them permission.
To change permissions for an item, follow steps 1-3 above. After you've added the name of the user
or group, click the drop-down to change the permission level for that user to Read/Write before
clicking Share.

Stop sharing an item


Go to the file or folder, right-click and choose Give access to > Remove access.

Customising Files and directories using the File Explorer


You can reconfigure certain ways that File Explorer works. All the configuration settings in
Windows 10 are in a window named Folder Options.

This window has three tabs filled with settings. Here’s how to access the Folder Options window,
browse its settings, change them, and apply your desired configuration:

1. Open File Explorer.


2. Click View.
The View menu appears.
3. Click Options.

The Folder Options window appears at the General tab. Here are settings for browsing folders in
File Explorer, opening an item in File Explorer, and whether to show recently used files and folders
in Quick Access.

1. In the General tab, change the settings that you’re interested in.
2. Click the View tab.

165
Figure 53:Customising Files and directories using the File Explorer

Here you find settings for viewing files and folders in File Explorer.

The list of settings is long. Browse through the list and read what they do. Each name is self-
explanatory.
3. Change any advanced settings that you want.
4. Click the Search tab.

Here you find settings for using search in Windows 10 and in File Explorer.

166
The Search tab in Folder Options.
5. Change how search works.
6. To apply your settings, click OK.

Configuring Local security policy settings


You must have Administrators rights on the local device, or you must have the appropriate
permissions to update a Group Policy Object (GPO) on the domain controller to perform these
procedures.

When a local setting is inaccessible, it indicates that a GPO currently controls that setting.
To configure a setting using the Local Security Policy console
1. To open Local Security Policy, on the Start screen, type secpol.msc, and then press ENTER.
2. Under Security Settings of the console tree, do one of the following:

167
Figure 54:Configuring Local security policy

o Click Account Policies to edit the Password Policy or Account Lockout Policy.
o Click Local Policies to edit an Audit Policy, a User Rights Assignment, or Security
Options.
3. When you find the policy setting in the details pane, double-click the security policy that you
want to modify.
4. Modify the security policy setting, and then click OK.
Note
o Some security policy settings require that the device be restarted before the setting takes
effect.
o Any change to the user rights assignment for an account becomes effective the next
time the owner of the account logs on.

To configure a security policy setting using the Local Group Policy Editor console
You must have the appropriate permissions to install and use the Microsoft Management Console
(MMC), and to update a Group Policy Object (GPO) on the domain controller to perform these
procedures.
1. Open the Local Group Policy Editor (gpedit.msc).
2. In the console tree, click Computer Configuration, click Windows Settings, and then
click Security Settings.
3. Do one of the following:
o Click Account Policies to edit the Password Policy or Account Lockout Policy.
o Click Local Policies to edit an Audit Policy, a User Rights Assignment, or Security
Options.
4. In the details pane, double-click the security policy setting that you want to modify.
Note
If this security policy has not yet been defined, select the Define these policy settings check
box.
5. Modify the security policy setting, and then click OK.

Note
If you want to configure security settings for many devices on your network, you can use the Group
Policy Management Console.

Conclusion
At the end of this learning outcome, the learner should be able to explain file management, file
access methods, file allocation techniques, file protection and security and demonstrate file and
directory operations and local policy settings

Further Reading
1. https://www.tutorialspoint.com/operating_system/os_file_system.htm
2. https://www.tutorialspoint.com/computer_concepts/computer_concepts_file_management_syste
m.htm
168
3.3.6. 3 Self-assessment
Written Assessment
1. What is a file?
2. Outline five file operations
3. Which attributes does a file possess?
4. How does contiguous allocation allocate file space?
5. Which are the three classification of users under the condensed version of the access control
list?

Oral Assessment
Describe available file protection and security operating system mechanisms

Practical Assessment
1. Select a file from a folder in your computer and set its permissions and share it to everyone on
your network.
2. Configure folder options to ensure all hidden files, folders and drives are displayed.

3.3.6.4. Tools, Equipment, Supplies and Materials


• Computer
• Internet
• Stationery
• Stationery
• Instruction material

3.3.6.5 References

1. https://www.tutorialspoint.com/File-System-Management
2. https://www.geeksforgeeks.org/protection-in-file-system/?ref=rp
3. https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-
settings/how-to-configure-security-policy-settings

169
CHAPTER 4: MATHEMATICS FOR COMPUTER SCIENCE

4.1 Introduction
This unit covers the competencies required to understand Mathematics for Computer Science. It
involves understanding Linear Algebra, understanding Boolean algebra, understanding Set Theory,
understanding Calculus and understanding Probability and Statistics.

4.2 Performance Standard


1. Solved Linear equations
2. Performed vector operations
3. Performed matrix operations
4. Performed Boolean algebra operations
5. Performed set operations
6. Explained samples spaces, events and sets
7. Solved problems using Probability axioms
8. Solved permutations and combinations
9. Solved problems using conditional probability
10. Represented data using statistical technique
11. Illustrated measures of central tendency
12. Illustrated measures of spread
13. Illustrated measures of location

4.3 Learning Outcomes


4.3.1 List of Learning Outcomes
1. Understand Linear Algebra
2. Understand Boolean Algebra
3. Understand Set Theory

170
4. Understand Calculus
5. Understand Probability and Statistics

171
4.3.2 Learning Outcome 1: Understand Linear Algebra
4.3.2.1 Learning Activities
Learning Outcome 1: Understand Linear Algebra
Learning Activities Special Instructions

1.1 Linear Equations are explained Activities may be carried out in


1.2 Linear equations are solved groups or as individual
1.3 Vectors are explained
1.4 Vector operations are illustrated
1.5 Matrices are explained
1.6 Matrix operations are illustrated
1.7 Inverse of a square matrix is illustrated

4.3.2.2 Information Sheet No 4/LO1: Understand Linear Algebra

Introduction
This learning outcome covers explaining and solving linear equations, explaining and illustrating
vectors and matrix operations and illustrating inverse of a matrix.

Definitions
❏ Vector: A quantity with a magnitude (a non-negative number) and a direction is called a
vector

Linear Equations

A linear equation is any equation that can be written in the form

where a and b are real numbers and x is a variable.

Solving linear equations


Example: y = 2x + 1 is a linear equation:

172
The graph of y = 2x+1 is a straight line

Example 1:
• A linear equation is a polynomial of degree 1.
• In order to solve for the unknown variable, you must isolate the variable.
• In the order of operation, multiplication and division are completed before addition and
subtraction.

Solve for x in 5 x - 6 = 3 x - 8
Subtract 3x from both sides of the equation:

Add 6 to both sides of the equation:

Divide both sides by 2:

The answer is x = - 1

Example 2:
Solve for x in 4 x - 6 = 12 x - 30
Subtract 4x from both sides of the equation:

Add 30 to both sides of the equation

Divide both sides by 8:

The answer is x = 3
Check the solution by substituting 3 in the original equation for x. If the left side of the
equation equals the right side of the equation after the substitution, you have found the
correct answer.
• Left side: 4(3) - 6 = 6

173
• Right side: 12(3) - 30 = 6

Vectors

A vector is an object which has both magnitude as well as direction. It is usually represented by an
arrow which shows the direction (→) and its length shows the magnitude. The arrow which
indicates the vector has an arrowhead and its opposite end is the tail. It is denoted as V⃗ . The
magnitude of the vector is represented as |V|. Two vectors are termed as equal if they have equal
magnitudes and equal direction.

Vector Algebra Operations


Just like in usual Algebra, we also perform arithmetic operations such as addition, subtraction,
multiplication, in vectors. However, in the case of multiplication only, vectors have two
terminologies, such as dot product and cross product, which we are going to learn here.

Addition of Vectors
Let us consider there are two vectors P and Q, then the sum of these two vectors can be performed
when the tail of vector Q meets with the head of vector A. And during this addition, the magnitude
and direction of the vectors should not change. The vector addition follows two important laws,
which are;
• Commutative Law: P + Q = Q + P
• Associative Law: P + (Q + R) = (P + Q) + R

Subtraction of Vectors
Here, the direction of other vectors is reversed and then the addition is performed on both the given
vectors. If P and Q are the vectors, for which the subtraction method has to be performed, then we
invert the direction of another vector say for Q, to make it -Q. Now, we need to add vector P and -
Q. So here the direction of the vectors are opposite each other but the magnitude remains the same.
• P – Q = P + (-Q)

Multiplication of Vectors
If k is a scalar quantity and it is multiplied by a vector A, then the scalar multiplication is given by
kA. If k is positive then the direction of the vector kA is the same as vector A, but if the value of k
is negative, then the direction of vector kP will be opposite to the direction of vector A. And the
magnitude of the vector kP is given by |k|.

Dot Product
The dot product is often called a scalar product. It is represented using a dot(.) between two vectors.
Here, two coordinate vectors of equal length are multiplied in such a way that they result in a single
number. So basically when we take the scalar product of two vectors the result is either a number of
a scalar quantity. Suppose P and Q are two vectors, then the dot product for both the vectors is
given by;
• P.Q = |P| |Q| cos θ

174
If P and Q are both in the same direction, i.e. θ = 0°, then;
• P.Q = |P| |Q|

If P and Q are both orthogonal, i.e. θ = 90°, then;


• P.Q = 0 [since cos 90° = 0]

In vector algebra, if two vectors are given as;


P = [P1,P2,P3,P4,….,Pn] and Q = [Q1,Q2,Q3,Q4,….,Qn]

Then their dot product is given by;


• P.Q = P1Q1+P2Q2+P3Q3+……….PnQn

Cross Product
A cross product is denoted by the multiplication sign(x) between two vectors. It is a binary vector
operation, defined in a three-dimensional system. If P and Q are two independent vectors, then the
result of the cross product of these two vectors (P x Q) is perpendicular to both the vectors and
normal to the plane that contains both the vectors. It is represented by;
• P x Q = |P| |Q| sin θ

Vector Algebra Example


Question: Find the dot product of vectors P(1, 3, -4) and Q(3,−5, 2).
Ans: As per the vector algebra definition of the dot product, we know;
P.Q = P1Q1+P2Q2+P3Q3+……….PnQn

Therefore,
P.Q = 1.3 + 3. (-5) + (-4).2
= 3 – 15 – 8
= -20

Matrices
A matrix is a two - dimensional collection of elements. We use bold upper case letters to
denote matrices. For example,

is a matrix with two rows and three columns, or a 2 × 3 matrix. Individual elements are labeled
with the first subscript indicating the row, and the second indicating the column. An n -

175
element column vector may be considered an n × 1 matrix, and an n - element row vector may
be considered a 1 × n matrix.

Types of matrices
Symmetric Matrix: A square matrix is symmetric if elements with interchanged subscripts are equal:

For example,

is symmetric.

Hermitian Matrix: A square complex matrix is Hermitian if elements with interchanged subscripts
are equal to the complex conjugate of each other:

Toeplitz Matrix: A square matrix is Toeplitz if all elements along the upper left to lower right
diagonals are equal:

For example:

is Toeplitz.
Identity Matrix: A square matrix that is all zero except for ones along the main diagonal is the
identity matrix, denoted as I .
For example,

is a 4 × 4 identity matrix. Often a subscript is added to indicate the dimension, as

is an n × n identity matrix.

Triangular Matrix: All elements of a lower triangular matrix above the main diagonal are zero.
All elements of an upper triangular matrix below the main diagonal are zero. For example,

is a triangular matrix.

176
Matrix operations
Addition and subtraction

Two or more vectors or matrices of the same dimensions may be added or subtracted by
adding/subtracting individual elements.

For example, if

then

Matrix addition is commutative; that is, C = A + B = B + A .

Scalar multiplication

Two matrices, where the column dimension of the first (m) is equal to the row dimension of
the second, may be multiplied by forming the dot product of the rows of the first matrix and
the columns of the second; that is

For example, if

then

Matrix multiplication is not commutative; that is, C = AB ≠ BA . A matrix multiplying or


multiplied by the identity I is unchanged; that is, AI = IA = A.

We can multiply a number (a.k.a. scalar) by a matrix by multiplying every entry of the
matrix by the scalar this is denoted by juxtaposition or ·, with the scalar on the left:

177
Determinant

The determinant of a square matrix is a measure of scale change when the matrix is viewed as a
linear transformation. When the determinant of a matrix is zero, the matrix is indeterminate or
singular, and cannot be inverted. The rank of matrix |A| is the largest square array in A that has
nonzero determinant.

The determinant of matrix A is denoted as det (A) or |A|. Laplace’s method for computing
determinants uses cofactors , where a cofactor of a given matrix element ij is

called the minor of ij , is the matrix formed


by deleting the i row and j column of matrix A .

For 2 × 2 matrix

the cofactors are

The determinant is the sum of the products of matrix elements and cofactors for any row or
column. Thus

For a 3 × 3 matrix A ,

the cofactors are

so using the first column

178
Transposition

The transpose of a matrix, denoted with superscript T , is formed by interchanging row and
column elements:

is the transpose of A where

For example,

If the matrix is complex, the complex conjugate transpose is denoted as

The matrix is Hermitian if

Inverse of square matrix

A square matrix that multiplies another square matrix to produce the identity matrix is called
the inverse, and is denoted by a superscript − 1

if A is square, and (square) matrix F satisfies F A = I, then

i) F is called the inverse of A, and is denoted


ii) The matrix A is called invertible or nonsingular

If A doesn’t have an inverse, it’s called singular or noninvertible

Example 1

Example 2 - does not have an inverse

because

179
but you can’t have a − 2b = 1 and −a + 2b = 0

Conclusion
At the end of this learning outcome, the learner should be able to explain and solve linear equations,
explain and illustrate vectors and matrix operations and illustrate inverse of a matrix.

Further Reading
1. https://www.math-only-math.com/solving-linear-equations.html
2. http://www.sosmath.com/algebra/solve/solve1/s13/S1301/S1301.html
3. https://byjus.com/maths/vector-algebra/

4.3.2.3 Self-Assessment

Written Assessment
1. For each matrix below, determine the order and state whether it is a square matrix.

2. Verify that matrices A and B given below are inverses of each other.

3. Solve the given system – or show that no solution exists:

4. What is transposition in linear algebra?


5. Contrast a vector and a matrix.
6. Rank of the matrix A =
0 0 0 0
4 2 3 0
1 0 0 0
4 0 3 0

180
a. 0
b. 1
c. 2
d. 3
7. A set of linear equations is represented by the matrix equation Ax = b. The necessary
condition for the existence of a solution for this system is
A.A must be invertible
B. b must be linearly depended on the columns of A
C. b must be linearly independent of the columns of A
D.None of these
8. The system of linear equations
(4d - 1)x +y + z = 0
-y+z=0
(4d - 1) z = 0
has a non-trivial solution, if d equals
A. 1/2
B. 1/4
C. 3/4
D. 1
9. The rank of a 3 x 3 matrix C (= AB), found by multiplying a non-zero column matrix A of
size 3 x 1 and a non-zero row matrix B of size 1 x 3, is
A.0
B. 1
C. 2
D.3
10. If A and B are square matrices of size n x n, then which of the following statement is not
true?
A.det. (AB) = det (A) det (B)
B. det (kA) = kn det (A)
C. det (A + B) = det (A) + det (B)
D.det (AT) =1/det (A-1)

Oral Assessment
1. Why is y2 − 2 = 0 not a linear equation?
2. Explain inverse of square matrix.

Practical Assessment
1. Solve each of the following equations.

181
2. Verify that matrices A and B given below are inverses of each other.

4.3.2.4 Tools, Equipment, Supplies and Materials


● Calculator
● Computer
● Instruction material
● Stationery

4.3.2.5 References
1. http://people.math.harvard.edu/~jjchen/math21a/handouts/vectors.html
2. https://onlinelibrary.wiley.com/doi/pdf/10.1002/9780470890042.app1
3. https://www.math10.com/en/geometry/vectors-operations/vectors-operations.html
4. https://www.analyzemath.com/linear-algebra/matrices/matrices-examples-and-questions-
with-solutions.html

182
4.3.3 Learning outcome 2: Understand Boolean Algebra
4.3.3.1 Learning Activities
Learning Outcome 2: Understand Boolean Algebra
Learning Activities Special Instructions

2.1 Boolean algebra is explained Activities may be carried out


2.2 Basic Boolean operations are explained in groups or as individual
2.3 Secondary operations are explained
2.4 Writing of Boolean Expressions is illustrated
2.5 Methods of simplifying Boolean expressions are
illustrated
2.6 Boolean Laws and Theorems are illustrated
2.7 Simplification rules for Boolean expressions are
illustrated

Information Sheet No. 4/LO 2: Understand Boolean Algebra

Introduction:
This learning outcome covers explaining Boolean algebra, basic Boolean operations, secondary
operations, illustratingboolean expressions, simplifying Boolean expressions, illustrating Boolean
laws and theorems and simplification rules for Boolean expressions.

Boolean algebra
Boolean algebra is used to analyze and simplify the digital (logic) circuits. It uses only the binary
numbers that is 0 and 1. It is also referred to as Binary Algebra or Logic Algebra.

Boolean algebra is the mathematics we use to analyse digital gates and circuits. We can use these
“Laws of Boolean” to both reduce and simplify a complex Boolean expression in an attempt to
reduce the number of logic gates required. Boolean algebra is therefore a system of mathematics
based on logic that has its own set of rules or laws which are used to define and reduce Boolean
expressions.

Basic Boolean operations


AND, OR, NOT and Secondary operations NAND, NOR, EX-OR, EX-NOR; their algebraic
functions and truth tables

Boolean operations are well expressed as logic gates.

i) The logic gates are the main structural part of a digital system.
ii) Logic Gates are a block of hardware that produces signals of binary 1 or 0 when input logic
requirements are satisfied.

183
iii) Each gate has a distinct graphic symbol, and its operation can be described by means of algebraic
expressions.
iv) The seven basic logic gates include: primary operations (AND, OR, NOT), secondary operations
(XOR, NAND, NOR, and XNOR).
v) The relationship between the input-output binary variables for each gate can be represented in
tabular form by a truth table.
vi) Each gate has one or two binary input variables designated by A and B and one binary output
variable designated by x.

AND: The AND gate is an electronic circuit which gives a high output only if all its inputs are high.
The AND operation is represented by a dot (.) sign.

OR: The OR gate is an electronic circuit which gives a high output if one or more of its inputs are
high. The operation performed by an OR gate is represented by a plus (+) sign.

NOT: The NOT gate is an electronic circuit which produces an inverted version of the input at its
output. It is also known as an Inverter.

184
NAND: The NOT-AND (NAND) gate which is equal to an AND gate followed by a NOT gate. The
NAND gate gives a high output if any of the inputs are low. The NAND gate is represented by a
AND gate with a small circle on the output. The small circle represents inversion.

NOR: The NOT-OR (NOR) gate which is equal to an OR gate followed by a NOT gate. The NOR
gate gives a low output if any of the inputs are high. The NOR gate is represented by an OR gate with
a small circle on the output. The small circle represents inversion.

XOR: The 'Exclusive-OR' gate is a circuit which will give a high output if one of its inputs is high
but not both of them. The XOR operation is represented by an encircled plus sign.

185
XNOR: The 'Exclusive-NOR' gate is a circuit that does the inverse operation to the XOR gate. It will
give a low output if one of its inputs is high but not both of them. The small circle represents inversion.

Using Karnaugh Maps


A Karnaugh map provides a pictorial method of grouping together expressions with common
factors and therefore eliminating unwanted variables. The Karnaugh map can also be described as a
special arrangement of a truth table.
The diagram below illustrates the correspondence between the Karnaugh map and the truth table for
the general case of a two variable problem.

The Karnaugh map

Boolean Laws, Theorems and Expressions


Table 12: Boolean Laws, Theorems and Expressions
Laws and Theorems Statements Expressions

AND law These laws use the AND


operation. Therefore they
are called AND laws

OR law These laws use the OR


operation. Therefore they
are called OR laws

186
Inversion law This law uses the NOT
operation. The inversion
law states that double
inversion of a variable
results in the original
variable itself

Commutative law Any binary operation (a) A + B = B + A


which satisfies the (b) A B = B A
following expression is
referred to as commutative
operation

Associative law This law states that the (a) (A + B) + C = A + (B + C)


order in which the logic (b) (A B) C = A (B C)
operations are performed is
irrelevant as their effect is
the same

Distributive law This law permits the (a) A (B + C) = A B + A C


multiplying or factoring (b) A + (B C) = (A + B) (A + C)
out of an expression

De-Morgan’s Theorems There are two “de (a)


Morgan´s” rules or
theorems, (b)

(1) Two separate terms


NOR´ed together is the
same as the two terms
inverted (Complement)
and AND´ed for example:

(2) Two separate terms


NAND´ed together is the
same as the two terms
inverted (Complement)
and OR´ed for example:

187
Simplification (Reduction) Rules for Boolean expressions
Let us consider an example of a Boolean function: AB+A (B+C) + B (B+C)
The logic diagram for the Boolean function AB+A (B+C) + B (B+C) can be represented as:
Sample logic diagram 1

We will simplify this Boolean function on the basis of rules given by Boolean algebra.
AB + A (B+C) + B (B+C)
AB + AB + AC + BB + BC {Distributive law; A (B+C) = AB+AC, B (B+C) = BB+BC}
AB + AB + AC + B + BC {Idempotent law; BB = B}
AB + AC + B + BC {Idempotent law; AB+AB = AB}
AB + AC +B {Absorption law; B+BC = B}
B + AC {Absorption law; AB+B = B}

Hence, the simplified Boolean function will be B + AC.

The logic diagram for Boolean function B + AC can be represented as:


Sample logic diagram 2

Conclusion:
At the end of this learning outcome, the learner should be able to explain Boolean algebra, basic
Boolean operations, secondary operations, illustrate Boolean expressions, simplify Boolean
expressions, illustrate Boolean laws and theorems and illustrate simplification rules for Boolean
expressions.

Further Reading
1. Wolfram, S. A New Kind of Science. Champaign, IL: Wolfram Media, p. 1168, 2002
2. http://www.ee.surrey.ac.uk/Projects/Labview/minimisation/karnaugh.html

188
4.3.3.3 Self-Assessment

Written Assessment
1. Simplify the Boolean expression (A+B+C)(D+E)' + (A+B+C)(D+E) and choose the best
answer.
1. A + B + C
2. D + E
3. A'B'C'
4. D'E'
5. None of the above
2. Which of the following relationships represents the dual of the Boolean property x + x'y = x
+ y?
1. x'(x + y') = x'y'
2. x(x'y) = xy
3. x*x' + y = xy
4. x'(xy') = x'y'
5. x(x' + y) = xy
3. Given the function F(X,Y,Z) = XZ + Z(X'+ XY), the equivalent most simplified Boolean
representation for F is:
1. Z + YZ
2. Z + XYZ
3. XZ
4. X + YZ
5. None of the above
4. Which of the following Boolean functions is algebraically complete?
1. F = xy
2. F = x + y
3. F = x'
4. F = xy + yz
5. F = x + y'
5. The logic gate that provides high output for same inputs ____________
a) NOT
b) X-NOR
c) AND
d) XOR
6. Algebra of logic is termed as
a. Numerical logic
b. Boolean algebra
c. Arithmetic logic
d. Boolean number
7. F(X,Y,Z,M) = X`Y`Z`M`. The degree of the function is
a. 2
b. 5

189
c. 4
d. 1
8. Boolean algebra can be used
a. For designing of the digital computers
b. Circuit theory
c. Building algebraic functions
d. In building logic symbols
9. A ______ value is represented by a Boolean expression.
a. Positive
b. Recursive
c. Negative
d. Boolean
10. What is the logic gate that provides high output for same inputs?
a. NOT
b. X-NOR
c. AND
d. XOR

Oral Assessment

1. Name and explain 5 Boolean laws


2. Explain the De-Morgan’s Theorem

Practical Assessment
1. Given that F = A'B'+ C'+ D'+ E', which of the following represent the only correct
expression for F'?
1. F'= A+B+C+D+E
2. F'= ABCDE
3. F'= AB(C+D+E)
4. F'= AB+C'+D'+E'
5. F'= (A+B)CDE
2. An equivalent representation for the Boolean expression A' + 1 is
1. A
2. A'
3. 1
4. 0
3. Simplification of the Boolean expression AB + ABC + ABCD + ABCDE + ABCDEF yields
which of the following results?
1. ABCDEF
2. AB
3. AB + CD + EF
4. A + B + C + D + E + F
5. A + B(C+D(E+F))

190
4.3.3.4 Tools, Equipment, Supplies and Materials
● Internet
● Calculator
● Computer
● Instruction material
● Stationery

4.3.3.5 References
3. https://www.electronicshub.org/boolean-algebra-laws-and-theorems/
4. https://www.javatpoint.com/boolean-algebra

191
4.3.4 Learning outcome 3: Understand Set Theory
4.3.4.1 Learning Activities
Learning Outcome 3: Understand Set Theory
Learning Activities Special Instructions

3.1 Sets Theory is explained Activities may be carried out


3.2 Methods of Set representation are illustrated in groups or as individual
3.3 Cardinality of a set explained
3.4 Types of sets are illustrated
3.5 Venn Diagrams are illustrated
3.6 Set Operations are illustrated

4.3.4.2 Information Sheet No. 4/LO3: Understand Set Theory

Introduction:
This learning outcome covers explaining set theory, illustrating methods of set representation,
explaining cardinality of a set, illustrating types of sets, Venn diagrams and set operations.

Definitions
Set theory: Set theory is the mathematical theory of well-determined collections, called sets, of
objects that are called members, or elements, of the set
Set Theory
A set is a collection of distinct objects, called elements of the set
A set can be defined by describing the contents, or by listing the elements of the set, enclosed in curly
brackets.
A set simply specifies the contents; order is not important. The set represented by {1, 2, 3} is
equivalent to the set {3, 1, 2}.

Notation
Commonly, we will use a variable to represent a set, to make it easier to refer to that set later.
The symbol ∈ means “is an element of”.
A set that contains no elements, { }, is called the empty set and is notated ∅
Let A = {1, 2, 3, 4}
To notate that 2 is element of the set, we’d write 2 ∈ A

Subset

A subset of a set A is another set that contains only elements from the set A, but may not contain all
the elements of A.

If B is a subset of A, we write B ⊆ A
A proper subset is a subset that is not identical to the original set—it contains fewer elements.
192
If B is a proper subset of A, we write B ⊂ A

Methods of Set representation


A set can be represented by various methods. 3 common methods used for representing set:
1. Statement form.
2. Roaster form or tabular form method.
3. Set Builder method.

Statement form
In this representation, the well-defined description of the elements of the set is given. Below are some
examples of the same.
1. The set of all even number less than 10.
2. The set of the number less than 10 and more than 1.

Roster form
In this representation, elements are listed within the pair of brackets {} and are separated by commas.
Below are two examples.
1. Let N is the set of natural numbers less than 5.
N = { 1 , 2 , 3, 4 }.
2. The set of all vowels in the English alphabet.
V = { a , e , i , o , u }.

Set builder form


In Set-builder set is described by a property that its member must satisfy.
1. {x : x is even number divisible by 6 and less than 100}.
2. {x : x is natural number less than 10}.

Cardinality of a set
The number of elements in a set is the cardinality of that set. The cardinality of the set A is often
notated as |A| or n(A)

For example; Let A = {1, 2, 3, 4, 5, 6} and B = {2, 4, 6, 8}.


What is the cardinality of B? A ⋃ B, A ⋂ B?

Answers:
The cardinality of B is 4, since there are 4 elements in the set.
The cardinality of A ⋃ B is 7, since A ⋃ B = {1, 2, 3, 4, 5, 6, 8}, which contains 7 elements.
The cardinality of A ⋂ B is 3, since A ⋂ B = {2, 4, 6}, which contains 3 elements.

Types of sets
There are many types of set in the set theory:

Singleton set
193
If a set contains only one element it is called to be a singleton set.
Hence the set given by {1}, {0}, {a} are all consisting of only one element and therefore are singleton
sets.

Finite Set
A set consisting of a natural number of objects, i.e. in which number element is finite is said to be a
finite set. Consider the sets
A = { 5, 7, 9, 11} and B = { 4 , 8 , 16, 32, 64, 128}

Obviously, A, B contain a finite number of elements, i.e. 4 objects in A and 6 in B. Thus they are
finite sets.

Infinite set
If the number of elements in a set is finite, the set is said to be an infinite set.
Thus the set of all natural numbers is given by N = { 1, 2, 3, ...} is an infinite set. Similarly the set of
all rational number between ) and 1 given by
A = {x:x E Q, 0 <x<1} is an infinite set.

Equal set
Two set A and B consisting of the same elements are said to be equal sets. In other words, if an
element of the set A sets the set A and B are called equal i.e. A = B.

Null set/ empty set


A null set or an empty set is a valid set with no member.
A = { } / phie cardinality of A is 0.
Popular representation either empty curly braces { } or a special symbol phie. This A is a set which
has null set inside it.

Venn Diagrams and Set Operations


To visualize the interaction of sets, John Venn in 1880 thought to use overlapping circles, building
on a similar idea used by Leonhard Euler in the eighteenth century. These illustrations are called
Venn Diagrams.

A Venn diagram represents each set by a circle, usually drawn inside of a containing box representing
the universal set. Overlapping areas indicate elements common to both sets.For example; set A{1, 2,
4, 8} is represented as:
Sample Venn diagram

Figure 55:Venn diagram

194
Set Operations: Set Union, Set Intersection, Complement of Set
The union of two sets contains all the elements contained in either set (or both sets). The union is
notated A ⋃ B. More formally, x ∊ A ⋃ B if x ∈ A or x ∈ B (or both)
Union of two sets

The intersection of two sets contains only the elements that are in both sets. The intersection is
notated A ⋂ B. More formally, x ∈ A ⋂ B if x ∈ A and x ∈ B.

Intersection of two sets

Figure 56:Intersection of two sets

The complement of a set A contains everything that is not in the set A. The complement is notated
A’, or Ac, or sometimes ~A.
Complement of a set A

Figure 57:Complement of a set

Universal set
A universal set is a set that contains all the elements we are interested in. This would have to be
defined by the context.

A complement is relative to the universal set, so Ac contains all the elements in the universal set that
are not in A.
Universal set

195
Figure 58:Universal set

‘U’ denotes the universal set. Above Venn diagram shows that A is a subset of B

Cartesian Products
Let A and B be two sets. Cartesian product of A and B is denoted by A × B, is the set of all ordered
pairs (a,b), where a belong to A and b belong to B.
A × B = {(a, b) | a ∈ A ∧ b ∈ B}.

For example; the Cartesian product of A = {1,2} and B = {p, q, r} is


A × B ={(1, p), (1, q), (1, r), (2, p), (2, q), (2, r) };

Conclusion
At the end of this learning outcome, the learner should be able to explain set theory, illustrate methods
of set representation, explain cardinality of a set, illustrate types of sets, Venn diagrams and set
operations.

Further Reading
https://www.mbacrystalball.com/blog/2015/10/09/set-theory-tutorial/

4.3.4.3 Self-Assessment
Written Assessment
1. There are 30 students in a class. Among them, 8 students are learning both English and French.
A total of 18 students are learning English. If every student is learning at least one language,
how many students are learning French in total?
a. 30
b. 22
c. 20
d. 24
2. In a group, there were 115 people whose proofs of identity were being verified. Some had
passport, some had voter id and some had both. If 65 had passport and 30 had both, how many
had voter id only and not passport?
A. 30
B. 50
C. 80
D. None of the above
3. Among a group of people, 40% liked red, 30% liked blue and 30% liked green. 7% liked both
red and green, 5% liked both red and blue, and 10% liked both green and blue. If 86% of them
liked at least one colour, what percentage of people liked all three?
A. 10
B. 6
C. 8
D. None
4. The set A = {1, 3, 5}. What is a larger set this might be a subset of?
196
a. 2,4,6
b. 2,6,8
c. 5,7,9
d. 7,8,9
5. If A and B are sets and A⋃B = A⋂B, then
a. A=B
b. A= θ
c. B= θ
d. None of these
6. If X and Y are two sets then X⋂(Y⋃X) equals
A. Y
B. Θ
C. X
D. None of these
7. The number of elements in the power set of the set {{a, b},c} is
a. 7
b. 3
c. 4
d. 8
8. Order of the power set of a set of order n is
a. 2^n
b. n^2
c. 2n
d. n
9. In a beauty contest half the number of experts voted for Mr. A and two thirds voted for Mr.
B. Ten voted for both and six did not vote for either. How many experts were there in total?
a. 18
b. 24
c. 36
d. None of these
10. Let n (A) denote the number of elements in set A if n(A) = p and n(B) =q then how many
ordered pairs (a, b) are there with a ∈A and b ∈B?
a. 2pq
b. p x q
c. p^2
d. p + q
Oral Assessment
1. What is cardinality?
2. Define set theory.
Practical Assessment
1. Consider the sets:
A = {red, green, blue}
B = {red, yellow, orange}
197
C = {red, orange, yellow, green, blue, purple}

Find A ⋃ B
Find A ⋂ B
Find Ac⋂ C
2. Among a group of students, 50 played cricket, 50 played hockey and 40 played volleyball. 15
played both cricket and hockey, 20 played both hockey and volleyball, 15 played cricket and
volleyball and 10 played all three. If every student played at least one game, find the number
of students and how many played only cricket, only hockey and only volley ball?

4.3.4.4 Tools, Equipment, Supplies and Materials


● Internet
● Calculator
● Computer
● Instruction material
● Stationery

4.3.4.5 References
1. https://www.britannica.com/science/set-theory
2. https://courses.lumenlearning.com/atd-hostos-introcollegemath/chapter/set-theory

198
4.3.5 Learning outcome 4: Understand Calculus
4.3.5.1 Learning Activities
Learning Outcome 4: Understand Calculus
Learning Activities Special Instructions

4.1 Functions and graphs are explained Activities may be carried out
4.2 Differential calculus is illustrated in groups or as individual
4.3 Integral calculus is illustrated

4.3.5.2 Information Sheet No. 4/LO4: Understand Calculus

Introduction:
This learning outcome covers explaining functions and graphs and illustrating differential and
integral calculus.

Definitions
Calculus: The word Calculus comes from Latin meaning "small stone", because it is like
understanding something by looking at small pieces

Differential calculus: Differential Calculus cuts something into small pieces to find how it changes

Integral calculus: Integral Calculus joins (integrates) the small pieces together to find how much
there is

Functions
What exactly is a function? An equation will be a function if, for any x in the domain of the equation
(the domain is all the x’s that can be plugged into the equation), the equation will yield exactly one
value of y when we evaluate the equation at a specific x.

For example: y = x2 +1
is a function because given an x, there is only one way to square it and then add 1 to the result. So,
no matter what value of x you put into the equation, there is only one possible value of y when we
evaluate the equation at that value of x.

y2 = x+1 is not a function because there are two possible values of y that we could use here. We
could use y=2 or y=−2. Since there are two possible values of y that we get from a single x, then
this equation isn’t a function.

199
Domain and range of a function
In simplest terms the domain of a function is the set of all values that can be plugged into a function
and have the function exist and have a real number for a value. So, for the domain we need to avoid
division by zero, square roots of negative numbers, logarithms of zero and logarithms of negative
numbers etc.

The range of a function is simply the set of all possible values that a function can take.

For example; Find the domain and range of each of the following functions.
f(x)=5x−3
We know that this is a line and that it’s not a horizontal line (because the slope is 5 and not zero…).
This means that this function can take on any value and so the range is all real numbers. Using
“mathematical” notation this is,
Range:(−∞,∞)
This is more generally a polynomial and we know that we can plug any value into a polynomial and
so the domain in this case is also all real numbers or,
Domain:−∞<x<∞or(−∞,∞) of functions
Many of the basic functions of calculus could be expressed as graphs

For example;
Example 1

This is a line in the slope intercept form y=mx+b

Graph 1: Demonstrating y = mx+c

Example 2

There really isn’t much to this problem outside of reminding ourselves of what absolute value is.
Recall that the absolute value function is defined as,

200
The graph is then,

Graph 2: f(x) = |x|


Example 3

Again, there really isn’t much to this other than to make sure it’s been graphed somewhere so we
can say we’ve done it

Graph 3: y = x3

Limits
Limits are all about approaching. Sometimes you can't work something out directly, but you can
see what it should be as you get closer and closer!

201
For example; The limit of (x2−1)/(x−1) as x approaches 1 is 2
And it is written in symbols as:

As a graph it looks like this:

So, in truth, we cannot say what the value at x=1 is. But we can say that as we approach 1, the limit
is 2.
Intercepts
X Intercept: where the graph of an equation crosses the x-axis; Y Intercept: where the graph of an
equation crosses the y-axis

When you want the x intercepts (x,0): Set y=0 then solve for x
When you want the y intercepts (0,y): Set x=0 then solve for y
For example; Find the intercepts of y = x2 − 4
x intercept: set y=0; 0 = x2 − 4; x2 = 4; x = 2 or −2
The points are (2,0) and (−2,0)

y intercept: set x=0; y = 02 − 4; y = −4


The point is (0,-4)

And here is the graph of x2 - 4 to confirm what we found:


202
Differential calculus

Derivatives (Differential Calculus): The Derivative is the "rate of change" or slope of a function.

Slope = Change in Y / Change in X

To find the derivative of a function y = f(x) we use the slope formula


Slope = Change in Y / Change in X = Δy / Δx

And (from the diagram above) we see that:


x changes from x to x+Δx
y changes from f(x) to f(x+Δx)

Now follow these steps:


Fill in this slope formula: ΔyΔx = f(x+Δx) − f(x)Δx

203
Simplify it as best we can, then make Δx shrink towards zero. Like this:

We write dx instead of "Δx heads towards 0".

And "the derivative of" is commonly written :

204
Common functions and rules of Derivatives
There are rules we can follow to find many derivatives.
For example:
● The slope of a constant value (like 3) is always 0
● The slope of a line like 2x is 2, or 3x is 3 etc

Common functions and rules of Derivatives


Table 13: Commo derivative functions

Table 14: Common Derivative Rules

205
First and second order differential equations

A first order differential equation is of the form:

Second order differential equations are in the form, ay″+by′+cy=0


(Homogeneous Linear Equations with constant coefficients)

The characteristic equation is:

Integral calculus
Integration can be used to find areas, volumes, central points and many useful things. But it is
easiest to start with finding the area under the curve of a function like this

206
What is the area under y = f(x)? We write dx to mean the Δx is approaching zero

The symbol for "Integral" is a stylish "S" (for "Sum", the idea of summing slices). After the Integral
Symbol we put the function we want to find the integral of (called the Integrand), and then finish
with dx to mean the slices go in the x direction (and approach zero in width)

Example: What is an integral of 2x?


We know that the derivative of x2 is 2x
... so an integral of 2x is x2

Notation

where C is the constant of integration.

Definite and Indefinite


A Definite Integral has actual values to calculate between (they are put at the bottom and top of the
"S"):

207
Graph 4: Indefinite integral

Graph 5: Definite integral


Techniques of integration
The techniques/rules of integration are as summarized on the table below:

Table 15: The techniques/rules of integration

Rules Function Integral

Multiplication by constant ∫cf(x) dx c∫f(x) dx

Power Rule (n≠-1) ∫xn dx (xn+1 /n+1) + C

Sum Rule ∫(f + g) dx ∫f dx + ∫g dx

Difference Rule ∫(f - g) dx ∫f dx - ∫g dx

Integration by Parts Integration by Parts is a special method of integration that is


often useful when two functions are multiplied together, but is
also helpful in other ways;
∫u v dx = u∫v dx −∫u' (∫v dx) dx
where u is the function u(x); v is the function v(x) and u' is the
derivative of the function u(x)

Substitution Rule "Integration by Substitution" (also called "u-Substitution" or


"The Reverse Chain Rule") is a method to find an integral, but
only when it can be set up in a special way

Note that we have g(x) and its derivative g'(x)


Conclusion:
208
At the end of this learning outcome, the learner should be able to explain functions and graphis and
illustrate differential and integral calculus.

Further Reading
http://tutorial.math.lamar.edu

4.3.5.3 Self-Assessment

Written Assessment
1. The function of f(x)=3x(x-2) has a maximum at
a. X=1
b. X=2
c. Both of the above
d. None of the above
2. The function of f(x)=3x(x-2) has a minimum at
a. X=1
b. X=2
c. Both of the above
d. None of the above
3. Maxima and minima occur
a. Simultaneously
b. Once
c. Alternately
d. Rarely
4. What is the integral of 1/x ?
a. X^2
b. lnx
c. x
d. 2x
5. If x+y=k, x>0,y>0 then xy is maximum when
a. x=ky
b. kx=y
c. x=y
d. None of these
6. What is the derivative of 3x^5+4?
a. 15x
b. 15x^2
c. 15x^3
d. 15x^4
7. Area bounded by the parabola 2y=x^2 and the line x=y-4 is equal to
a. 18
b. 6
c. Infinite

209
d. None of these
8. The minimum value of |x ^2-5x+21| is
a. 0
b. -1
c. -2
d. -5
9. Sum of the perimeters of a circle and a square is 1. If sum of the area is least, then
a. Side of the square is double the radius of the circle
b. Side of the square if half the radius of the circle
c. Side of the square is equal to the radius of the circle
d. None of these
10. The limit of the function f(x)=[1-a^4/x^4] as x approaches infinity is given by
a. exp[-a^4]
b. 1
c. Infinity
d. Zero
Oral Assessment
1. Explain the power rule in differential calculus
2. Differentiate between first order and second order differential equations

Practical Assessment
1. Evaluate

2. What is the derivative of sin(x)?

4.3.5.4 Tools, Equipment, Supplies and Materials


● Internet
● Calculator
● Computer
● Instruction material
● Stationery
4.3.5.5 References
1. https://www.mathsisfun.com/calculus/derivatives-introduction.html
2. http://www.sosmath.com/tables/diffeq/diffeq.html

210
4.3.6 Learning outcome 5: Understand Probability and Statistics
4.3.6.1 Learning Activities

Learning Outcome 5: Understand Probability and Statistics


Learning Activities Special Instructions

5.1 Key terminologies in Probability are explained Activities may be carried out
5.2 Probability axioms and simple counting problems are in groups or as individual
illustrated
5.3 Permutations and combinations are illustrated
5.4 Conditional probability and the multiplication rule are
illustrated
5.5 Key terminologies in Statistics are explained
5.6 Data representation techniques are illustrated
5.7. Measures of central tendency are illustrated
5.8 Measures of spread are illustrated
5. 9 Measure of Location are illustrated

4.3.6.2 Information Sheet No.4/LO5: Understand Probability and Statistics


Introduction:
This learning outcome covers explaining key terminologies in probability and statistics, illustrating
probability axioms and simple counting problems, permutations and combinations, conditional
probability and multiplication rule, measures of central tendency, measures of spread and measures
of location.

Definitions
❏ Probability: Probability is the measure of the likelihood that an event will occur in a
random Experiment
❏ Sample space: The set of all possible outcomes of a game, experiment or other situation.
❏ Independence: The occurrence of one event does not affect the probability of the
occurrence of another.
❏ Probability theory: The mathematical study of probability (the likelihood of occurrence of
random events in order to predict the behavior of defined systems).
Probability Axioms
We assign a probability measure P(A) to an event A. This is a value between 0 and 1 that shows
how likely the event is. If P(A) is close to 0, it is very unlikely that the event A occurs. On the other
hand, if P(A) is close to 1, A is very likely to occur. The main subject of probability theory is to
develop tools and techniques to calculate probabilities of different events. Probability theory is
based on some axioms that act as the foundation for the theory.

Axioms of Probability:
• Axiom 1: For any event A, P(A)≥0.
• Axiom 2: Probability of the sample space S is P(S)=1
211
• Axiom 3: If A1,A2,A3,⋯ are disjoint events, then

P(A1∪A2∪A3⋯)=P(A1)+P(A2)+P(A3)+⋯

The first axiom states that probability cannot be negative. The smallest value for P(A) is zero and
if P(A)=0, then the event A will never happen.

The second axiom states that the probability of the whole sample space is equal to one, i.e., 100
percent. The reason for this is that the sample space S contains all possible outcomes of our random
experiment. Thus, the outcome of each trial always belongs to S, i.e., the event S always occurs
and P(S)=1. In the example of rolling a die, S={1,2,3,4,5,6, and since the outcome is always among
the numbers 1 through 6, P(S)=1.

The third axiom is probably the most interesting one. The basic idea is that if some events are
disjoint (i.e., there is no overlap between them), then the probability of their union must be the
summations of their probabilities.

Example 1

In a presidential election, there are four candidates. Call them A, B, C, and D. Based on our polling
analysis, we estimate that A has a 20 percent chance of winning the election, while B has a 40
percent chance of winning. What is the probability that A or B win the election?

Solution:
Notice that the events that {A wins}, {B wins}, {C wins}, and {D wins}are disjoint since more
than one of them cannot occur at the same time.

For example, if A wins, then B cannot win. From the third axiom of probability, the probability of
the union of two disjoint events is the summation of individual probabilities.

Therefore,
P(A wins or B wins) =P({A wins}∪{B wins})
=P({A wins})+P({B wins})
=0.2+0.4
=0.6

In summary, if A1 and A2 are disjoint events,


then

P(A1∪A2)=P(A1)+P(A2)

The same argument is true when you have n disjoint events A1,A2,⋯,An:
P(A1∪A2∪A3⋯∪An)=P(A1)+P(A2)+⋯+P(An), if A1,A2,⋯,An are disjoint.
212
In fact, the third axiom goes beyond that and states that the same is true even for a countably infinite
number of disjoint events.

As we have seen, when working with events, intersection means "and", and union means "or". The
probability of intersection of A and B, P(A∩B), is sometimes shown by P(A,B) or P(AB).

• P(A∩B)=P(A and B)=P(A,B),

• P(A∪B)=P(A or B).

Illustration of axioms
Suppose that we are given a random experiment with a sample space S. To find the probability of
an event, there are usually two steps:

first, we use the specific information that we have about the random experiment. Second, we use
the probability axioms.

Let's look at an example. Although this is a simple example and you might be tempted to write the
answer without following the steps, we encourage you to follow the steps.

Example 2

You roll a fair die. What is the probability of E={1,5}?

Solution
Let's first use the specific information that we have about the random experiment. The problem
states that the die is fair, which means that all six possible outcomes are equally likely, i.e.,
P({1})=P({2})=⋯=P({6}).

Now we can use the axioms of probability. In particular, since the events
{1},{2},⋯,{6}{1},{2},⋯,{6} are disjoint we can write
1 =P(S)
=P({1}∪{2}∪⋯∪{6})
=P({1})+P({2})+⋯+P({6})
=6P({1})

Thus,
P({1})=P({2})=⋯=P({6})=16.
Again since {1} and {5} are disjoint, we have
P(E)=P({1,5})=P({1})+P({5})=26=13.

213
It is worth noting that we often write P(1) instead of P({1}) to simplify the notation, but we should
emphasize that probability is defined for sets (events) not for individual outcomes. Thus, when we
write P(2)=16, what we really mean is that P({2})=16.

Permutations and combinations

When the order doesn't matter, it is a Combination. For example, a cloth with 3 colours - grey,
yellow and red. When describing the cloth, you name its colours irrespective of the order. We have
Combinations with Repetition and Combinations without Repetition

When the order does matter it is a Permutation. For example; "The combination to the safe is 472".
Now we do care about the order. "724" won't work, nor will "247". It has to be exactly 4-7-2

A permutation is an ordered Combination, classified into Permutations with Repetition and


Permutations without Repetition

Conditional probability and multiplication rule

Conditional probability is the probability of an event ( A ), given that another ( B ) has already
occurred.

Suppose we have two events A and B where the probability of event B is positive, that is P(B) > 0.
Then the probability of A given B is defined as the quotient
P(A|B)=P(A∩B)P(B)

The Multiplication Rule


In probability theory, the Multiplication Rule states that the probability that A and B occur is equal
to the probability that A occurs times the conditional probability that B occurs, given that we know
A has already occurred.

This rule can be written:


P(A∩B)=P(B)⋅P(A|B)

Example
Suppose that we draw two cards out of a deck of cards and let A be the event the the first card is
an ace, and B be the event that the second card is an ace, then:

P(A)=4/52

And:

214
P(B|A)=3/51

The denominator in the second equation is 51 since we know a card has already been drawn.
Therefore, there are 51 left in total. We also know the first card was an ace, therefore:

P(A∩B)=P(A)⋅P(B|A)=4/52⋅3/51=0.0045

Statististics
This is the practice or science of collecting and analysing numerical data in large quantities,
especially for the purpose of inferring proportions in a whole from those in a representative sample.

Data representation techniques (Data graphs)


A Bar Graph (also called Bar Chart) is a graphical display of data using bars of different
heights.

Line Graph: a graph that shows information that is connected in some way (such as change over
time)

215
Pie Chart: a special chart that uses "pie slices" to show relative sizes of data

A Dot Plot is a graphical display of data using dots

For example;
A survey of "How long does it take you to eat breakfast?" has these results:

Minutes:0 1 2 3 4 5 6 7 8 9 10 11 12
People:6 2 3 5 2 5 0 0 2 3 7 4 1
Which means that 6 people take 0 minutes to eat breakfast (they probably had no breakfast!), 2
people say they only spend 1 minute having breakfast, etc.
216
And here is the dot plot:

Histogram: a graphical display of data using bars of different heights

Measures of central tendency

Mean
Add up the numbers and divide by how many numbers
For example, mean of 2, 4, 6
2+4+6 = 12
12/2 = 6
Mode
Simply list all numbers in order and choose the middle one
For example; mode of 2, 4, 6 is 4 (middle number)

Median
The Mode is the value that occurs most often
For example; the median of 1,4,5,6,5,5,1 is 5

Measures of spread
Variance

217
The variance of a random variable X is a measure of how concentrated the distribution
of a random variable X is around its mean (The average of the squared differences from
the Mean).
To calculate the variance follow these steps:
● Work out the Mean (the simple average of the numbers)
● Then for each number: subtract the Mean and square the result (the squared
difference).
● Then work out the average of those squared differences.

Standard deviation
The Standard Deviation is a measure of how spread out numbers are. Its symbol is σ
(the greek letter sigma) and it is the square root of the Variance.
Example
Given the heights of wooden logs are: 600mm, 470mm, 170mm, 430mm and
300mm. Find out the Mean, the Variance, and the Standard Deviation
i) Mean
Mean = (600 + 470 + 170 + 430 + 300) /5
= (1970) /5
= 394

Variance
Variance = σ2
= (2062 + 762 + (−224)2 + 362 + (−94)2) /5
= (42436 + 5776 + 50176 + 1296 + 8836) /5
= 108520 /5
= 21704

Standard Deviation = σ
= √21704
= 147.32...
= 147 (to the nearest mm)
Measure of Location

Quartiles are the values that divide a list of numbers into quarters:
i) Put the list of numbers in order
ii) Then cut the list into four equal parts
iii) The Quartiles are at the "cuts"
For example, given the numbers 2, 4, 4, 5, 6, 7, 8; find the Quartiles

218
And the result is:
Quartile 1 (Q1) = 4
Quartile 2 (Q2), which is also the Median, = 5
Quartile 3 (Q3) = 7

Percentile: the value below which a percentage of data falls.


Example: You are the fourth tallest person in a group of 20
80% of people are shorter than you:

That means you are at the 80th percentile.


If your height is 1.85m then "1.85m" is the 80th percentile height in that group

Conclusion:
At the end of this learning outcome, the learner should be able to explain key terminologies in
probability and statistics, illustrate probability axioms and simple counting problems, permutations
and combinations, conditional probability and multiplication rule, measures of central tendency,
measures of spread and measures of location.

Further Reading
1 https://www.probabilitycourse.com/chapter1/
2. https://bgsu.instructure.com/courses/901773/pages/p5-definition-of-conditional-probability-
and-multiplying-probabilities?module_item_id=6367147
3. https://courses.lumenlearning.com/boundless-statistics/chapter/probability-rules/

4.3.6.3 Self-Assessment

Written Assessment
1. What are the quartiles for the following set of numbers?
13, 18, 6, 20, 25, 11, 9, 18, 3, 30, 16, 9, 8, 23, 26, 17
A. Q1 = 22.5, Q2 = 10.5, Q3 = 8.5
219
B. Q1 = 9, Q2 = 16.5, Q3 = 19
C. Q1 = 10, Q2 = 16.5, Q3 = 21.5
D. Q1 = 9, Q2 = 16.5, Q3 = 21.5
2. The following are the measures of central tendency except
a. Mean
b. Mode
c. Mass
d. Median
3. The following are scores made on a math test 80,90,90,85,60,70,75,85,90,60,80. What is the
median of these scores?
a. 80
b. 85
c. 70
d. 90
4. What is the mode of the following numbers 1,2,2,8,9,14?
a. 9
b. 14
c. 8
d. 2
5. Which set of data has a mean of 15, a range of 22, and a median of 14 and a mode of 14?
a. 14,22,15,15,9
b. 14,22,14,15,4
c. 25,15,14,3,7
d. 3,14,19,25,14
6. If the total sum of a square is 20 and the sample variance is 5 then the total number of
observations are
a. 25
b. 15
c. 35
d. 4
7. In a manufacturing company the number of employees in unit A is 40, the mean is $6400
and the number of employees in unit B is 30 with the mean of Rs. 5500 the combined
arithmetic mean is
a. 9500
b. 7014.29
c. 6014.29
d. 8000
8. The value of 1st quartile is 23 and the inter-quartile range is 20. What is the value of the 3rd
quartile
a. 73
b. 63
c. 53
d. 43

220
9. What is the probability of getting a sum 9 from two throws of a dice?
a. 1/8
b. 1/12
c. 1/6
d. 1/9
10. Three unbiased coins are tossed. What is the probability of getting at most two heads?
a. ¾
b. 3/8
c. 7/8
d. ¼
Oral Assessment
1. Name the measures of central tendency
2. What is variance and how does it relate to standard deviation?

Practical Assessment

1. Given the numbers 200, 300, 401, 225, 500, 630 and 900, calculate mean, variance
and standard deviation.

4.3.6.4 Tools, Equipment, Supplies and Materials


● Calculator
● Computer
● Instruction material
● Stationery
● Internet

4.3.6.5 References
1. https://www.mathsisfun.com/
2. https://www.mathsisfun.com/data/data-graph.php

221
CHAPTER 5: FUNDAMENTALS OF PROGRAMMING

5.1 Introduction
This unit covers the competencies required to understand fundamentals of programming. It involves
understanding programming concepts, understanding the Java environment, performing data
operations, using control structures, using methods and understanding Object Oriented programming.

5.2 Performance Standard


1. Installed Java
2. Demonstrated understanding of Java environment
3. Created a program to perform data operations
4. Created a program using control statements
5. Created a program using methods
6. Demonstrated classes and objects
7. Demonstrated inheritance

5.3 Learning Outcomes


5.3.1 List of Learning Outcomes
1. Understand Programming Concepts
2. Understand the Java environment
3. Perform Data Operations
4. Use Control Structures
5. Use Methods
6. Understand Object Oriented Programming

222
5.3.2 Learning Outcome 1: Understand programming concepts
5.3.2.1 Learning Activities
Learning Outcome No. 1: Understand Special Instructions
Programming Concepts

Learning Activities Activities may be carried out in


groups or as individual
1.1 Programming is defined
1.2 Phases of program development are explained
1.3 Key terms used in programming are explained
1.4 The types of code are explained
1.5 Different translators are used in programming
are explained
1.6 OOP fundamental concepts are explained

5.3.2.2 Information Sheet No 5/LO1: Understand Programming Concepts

Introduction
This learning outcome covers explaining programming, phases of program development, key
terms in programming, types of code, programming translators and OOP fundamental concepts.
Programming
Programming is the process of creating a set of instructions that tell a computer how to perform a
task. Programming can be done using a variety of computer "languages," such as SQL, Java,
Python, and C++.

Phases of program development


1. Establish program requirements
All possible requirements of the system to be developed are captured in this phase and
documented in a requirement specification document.

2. Design a program
The requirement specifications from the first phase are studied in this phase and the system
design is prepared. This system design helps in specifying hardware and system requirements and
helps in defining the overall system architecture.

3. Coding
With inputs from the system design, the system is first developed in small programs called units,
which are integrated in the next phase. Each unit is developed and tested for its functionality,
which is referred to as Unit Testing.

4. Code test and debug


223
All the units developed in the implementation phase are integrated into a system after testing of
each unit. Post integration the entire system is tested for any faults and failures. There are some
issues which come up in the client environment. To fix those issues, patches are released. Also to
enhance the product some better versions are released. Maintenance is done to deliver these
changes in the customer environment.

5. Document
In this phase all the information about the system is well documented

6. Maintain
There are some issues which come up in the client environment. To fix those issues, patches are
released. Also to enhance the product some better versions are released. Maintenance is done to
deliver these changes in the customer environment.

Key terms used in programming


Algorithm
An algorithm is a procedure or step-by-step instruction for solving a problem. They form the
foundation of writing a program.

Source code
Source code is the fundamental component of a computer program that is created by a
programmer. It can be read and easily understood by a human being

Executable
An executable is a file that contains a program - that is, a particular kind of file that is capable of
being executed or run as a program in the computer.

Compiling
It is the process which the source code undergo to produce an output with the help of an
executable program.

Debugging
Debugging is the routine process of locating and removing computer program bugs, errors or
abnormalities, which is methodically handled by software programmers via debugging tools.
Debugging checks, detects and corrects errors or bugs to allow proper program operation
according to set specifications.

Types of code
Source code
Source code is the list of human-readable instructions that a programmer writes often in a word
processing program when he is developing a program.

Object code

224
Object code is the output of a compiler after it processes source code

Machine code
Machine code is a computer program written in machine language. It uses the instruction set of a
particular computer architecture. It is usually written in binary. Machine code is the lowest level
of software.

Translators used in programming


Compiler
A compiler is a special program that processes statements written in a particular programming
language and turns them into machine language or “code” that a computer’s processor uses

Interpreter
An interpreter is a computer program, which coverts each high-level program statement into the
machine code. This includes source code, pre-compiled code, and scripts.

Assembler
An assembler is a program that converts assembly language into machine code. It takes the basic
commands and operations from assembly code and converts them into binary code that can be
recognized by a specific type of processor.

OOP fundamental concepts


It is a programming concept that works on the principle that objects are the most important part of
your program. It allows users to create the objects that they want and then create methods to
handle those objects. Manipulating these objects to get results is the goal of Object Oriented
Programming.

Conclusion
At the end of this learning outcome, the trainee should be able to explain phases of program
development, types of code and translators and understand the OOP programming concepts.

Further reading

What is Computer Programming? Basics to Learn Coding. Retrieved from


https://www.guru99.com/computer-programming-tutorial.html

5.3.2.3 Self-Assessment

Written Assessment
1. Which is the first stage in program development?
225
(a) Design a program
(b) Establish program requirements
(c) Coding
(d) Code test and debug
2. Which step of program development could project termination be done?
(a) Design a program
(b) Establish program requirements
(c) Coding
(d) System maintenance phase.
3. Which of the following is the most important phase in system development?
(a) Design a program
(b) Establish program requirements
(c) Establishing program requirement
(d) Code test and debug
4. Which of the following is NOT a programming translator?
(a) Compiler
(b) Interpreter
(c) Assembler
(d) CPU
5. What are the phases of program development?
6. What is an algorithm?
7. What is a compiler?

Oral Assessment
1. What do you understand by Object Oriented programming?
2. What are the common types of codes in java?

Practical Assessment
Research on which contemporary programming languages use compilers and those that use
translators
5.3.2.4 Tools, Equipment, Supplies and Materials
● Computer
● Internet
● Stationery
● Instruction material

5.3.2.5 References

1. https://www.tutorialspoint.com/computer_programming/index.htm

226
5.3.3 Learning outcome 2: Understand the Java Environment
5.3.3.1 Learning Activities

Learning Outcome No. 2: Understand The Special Instructions


Java Environment

Learning Activities Activities may be carried out in groups or as


individual
2.1 Java is installed
2.2 Java programming environment is
demonstrated
2.3 Features of Java are explained
2.4 Java syntax is demonstrated

5.3.3.2 Information Sheet No 5/LO2: Understand the Java Environment

Introduction
This learning outcome covers installing java, demonstrating the Java Environment, explaining
features of Java and demonstrating java syntax.

Installation of Java
The Java Development Kit (JDK) allows you to code and run Java programs. It's possible that you
install multiple JDK versions on the same PC. But it’s recommended that you install only the latest
version.

Following are steps to install Java in Windows


Step 1) Download Java for Windows and Install JDK, Go to link. Click on Download JDK.
Select the java latest version.

227
Step 2) Next,
1. Accept License Agreement
2. Download latest Java JDK for your version (32 or 64 bit) of java for Windows.

Step 3) Once the download is complete, run the exe for install JDK. Click Next

Step 4) Select the PATH for Java installation and click next.
228
Step 5) Once installation is complete, click Close

Set the Environment variables


2. The PATH variable gives the location of executables like javac, java etc. It is possible to run a
program without specifying the PATH but you will need to give full path of executable like
C:\Program Files\Java\jdk-13.0.1\bin\javac A.java instead of simple javac A.java
3. The CLASSPATH variable gives location of the Library Files.

Let's look into the steps to set the PATH and CLASSPATH
Step 1) Right Click on the My Computer and Select the properties

Step 2) Click on advanced system settings

229
Step 3) Click on Environment Variables

Step 4) Click on new Button of User variables

Step 5) Type PATH in the Variable name.

230
Step 6) Copy the path of bin folder which is installed in JDK folder.

Step 7) Paste Path of bin folder in Variable value and click on OK Button.

Note: In case you already have a PATH variable created in your PC, edit the PATH variable to
PATH = <JDK installation directory>\bin;%PATH%;
Here, %PATH% appends the existing path variable to our new value

Step 8) You can follow a similar process to set CLASSPATH.

Step 9) Click on OK button


Step 10) Go to command prompt and type javac commands.
If you see a screen like below, Java is installed.
231
Java Programming environment
1. Download the Eclipse Installer
Download Eclipse Installer from http://www.eclipse.org/downloads. Eclipse is hosted on many
mirrors around the world. Please select the one closest to you and start to download the Installer

2. Start the Eclipse Installer executable


For Windows users, after the Eclipse Installer executable has finished downloading it should be
available in your download directory.

Start the Eclipse Installer executable. You may get a security warning to run this file. If the Eclipse
Foundation is the Publisher, you are good to select Run.
For Mac and Linux users, you will still need to unzip the download to create the Installer. Start the
Installer once it is available.

3. Select the package to install


• The new Eclipse Installer shows the packages available to Eclipse users. You can search for
the package you want to install or scroll through the list.

232
• Select and click on the package you want to install.

4. Select your installation folder


• Specify the folder where you want Eclipse to be installed. The default folder will be in your
User directory.
• Select the ‘Install’ button to begin the installation.

5. Launch Eclipse
Once the installation is complete you can now launch Eclipse.

Features of Java
• Object Oriented
In Java, everything is an Object. Java can be easily extended since it is based on the Object model.
233
• Platform Independent
Unlike many other programming languages including C and C++, when Java is compiled, it is not
compiled into platform specific machine, rather into platform-independent byte code. This byte code
is distributed over the web and interpreted by the Virtual Machine (JVM) on whichever platform it is
being run on.
• Simple
Java is designed to be easy to learn. If you understand the basic concept of OOP Java, it would be
easy to master.
• Secure
With Java's secure feature it enables to develop virus-free, tamper-free systems. Authentication
techniques are based on public-key encryption.
• Architecture-neutral
Java compiler generates an architecture-neutral object file format, which makes the compiled code
executable on many processors, with the presence of Java runtime system.
• Portable
Being architecture-neutral and having no implementation dependent aspects of the specification
makes Java portable.
• Robust
Java makes an effort to eliminate error-prone situations by emphasizing mainly on compile time error
checking and runtime checking.
• Multithreaded
With Java's multithreaded feature it is possible to write programs that can perform many tasks
simultaneously. This design feature allows the developers to construct interactive applications that
can run smoothly.
• Interpreted
Java byte code is translated on the fly to native machine instructions and is not stored anywhere. The
development process is more rapid and analytical since the linking is an incremental and light-weight
process.
• High Performance
With the use of Just-In-Time compilers, Java enables high performance.
• Distributed
Java is designed for the distributed environment of the internet.
• Dynamic
Java is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving
environment. Java programs can carry an extensive amount of run-time information that can be used
to verify and resolve accesses to objects at run-time.

Java syntax
• Case Sensitivity
Java is case sensitive, which means identifier Hello and hello would have different meaning in
Java.
• Class names

234
For all class names the first letter should be in Upper Case. If several words are used to form a
name of the class, each inner word's first letter should be in Upper Case.
Example: class MyFirstJavaClass
• Method names
All method names should start with a Lower Case letter. If several words are used to form the name
of the method, then each inner word's first letter should be in Upper Case.

Example: public void myMethodName()


• Program file name
Name of the program file should exactly match the class name.
When saving the file, you should save it using the class name (Remember Java is case
sensitive) and append '.java' to the end of the name (if the file name and the class name do
not match, your program will not compile).
Note that in case you do not have a public class present in the file then file name can be different
than class name. It is also not mandatory to have a public class in the file.

Example: Assume 'MyFirstJavaProgram' is the class name. Then the file should be saved as
'MyFirstJavaProgram.java'
public static void main

In Java programs, the point from where the program starts its execution or simply the entry point of
Java programs is the main() method. Hence, it is one of the most important methods of Java and
having proper understanding of it is very important.

Most common syntax of main() method:


class GeeksforGeeks {
public static void main(String[]
args)
{
System.out.println("I am a
Geek");
}
}
I am a Geek
Explanation:
Every word in the public static void main statement has got a meaning to the JVM.
· Public: It is an Access modifier, which specifies from where and who can access the method.

Making the main() method public makes it globally available. It is made public so that JVM can
invoke it from outside the class as it is not present in the current class.

235
class GeeksforGeeks {
private static void main(String[]
args)
{
System.out.println("I am a
Geek");
}
}
Error: Main method not found in class, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

• ·Static: It is a keyword which is when associated with a method, makes it a class related
method. The main() method is static so that JVM can invoke it without instantiating the
class. This also saves the unnecessary wastage of memory which would have been used by
the object declared only for calling the main() method by the JVM.

class GeeksforGeeks {
public void main(String[] args)
{
System.out.println("I am a
Geek");
}
}
Error: Main method is not static in class test, please define the main method
as:
public static void main(String[] args)

Void: It is a keyword and used to specify that a method doesn’t return anything. As main() method
doesn’t return anything, its return type is void. As soon as the main() method terminates, the java
program terminates too. Hence, it doesn’t make any sense to return from main() method as JVM
can’t do anything with the return value of it.

class GeeksforGeeks {
public static int main(String[] args)
{
System.out.println("I am a
Geek");
return1;
}
}
Error: Main method not found in class, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

• main: It is the name of Java main method. It is the identifier that the JVM looks for as the
starting point of the java program. It’s not a keyword.
236
class GeeksforGeeks {
public static void myMain(String[]
args)
{
System.out.println("I am a Geek");
}
}
Error: Main method not found in class, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

• String[] args: It stores Java command line arguments and is an array of type
java.lang.String class. Here, the name of the String array is args but it is not fixed and user
can use any name in place of it.

class GeeksforGeeks {
// javac GeeksforGeeks.java
// java GeeksforGeeks 1 2 3
public static void main(String[]
args)
{
for(String elem : args)
System.out.println(elem);
}
}
1
2
3

Apart from the above mentioned signature of main, you could use public static void main(String
args[]) or public static void main(String… args) to call the main function in java. The main
method is called if it’s formal parameter matches that of an array of Strings

• Identifiers
In programming languages, identifiers are used for identification purpose. In Java, an identifier can
be a class name, method name, variable name or a label. For example :
public class Test
{
public static void main(String[] args)
{
int a = 20;
}
}

In the above java code, we have 5 identifiers namely :


● Test : class name.
237
● main : method name.
● String : predefined class name.
● args : variable name.
● a : variable name.

Rules for defining Java Identifiers


There are certain rules for defining a valid java identifier. These rules must be followed, otherwise
we get compile-time error. These rules are also valid for other languages like C,C++.
● The only allowed characters for identifiers are all alphanumeric characters([A-Z],[a-z],[0-
9]), ‘$‘(dollar sign) and ‘_‘ (underscore).For example “geek@” is not a valid java identifier
as it contain ‘@’ special character.
● Identifiers should not start with digits([0-9]). For example “123geeks” is a not a valid java
identifier.
● Java identifiers are case-sensitive.
● There is no limit on the length of the identifier but it is advisable to use an optimum length
of 4 – 15 letters only.
● Reserved words can’t be used as an identifier. For example “int while = 20;” is an invalid
statement as while is a reserved word. There are 53 reserved words in Java.

Modifiers
Modifiers are keywords that you add to those definitions to change their meanings. Java language
has a wide variety of modifiers, including the following −
• Java Access Modifiers
• Non Access Modifiers
To use a modifier, you include its keyword in the definition of a class, method, or variable. The
modifier precedes the rest of the statement, as in the following example.
public class className {
// ...
}

private boolean myFlag;


static final double weeks = 9.5;
protected static final int BOXWIDTH = 42;
public static void main(String[] arguments) {
// body of method
}
Access Control Modifiers
Java provides a number of access modifiers to set access levels for classes, variables, methods and
constructors. The four access levels are −
● Visible to the package, the default. No modifiers are needed.
● Visible to the class only (private).
● Visible to the world (public).
● Visible to the package and all subclasses (protected).

238
Non-Access Modifiers
Java provides a number of non-access modifiers to achieve many other functionality.
• The static modifier for creating class methods and variables.
• The final modifier for finalizing the implementations of classes, methods, and variables.
• The abstract modifier for creating abstract classes and methods.
• The synchronized and volatile modifiers, which are used for threads.

Variables
A variable can be thought of as a container which holds value for you, during the life of a Java
program. Every variable is assigned a data type which designates the type and quantity of value
it can hold.

Conclusion
At the end of this learning outcome, the trainee should be able to install Java, understand java
programming environment, explain features of Java and understand the java syntax.

Further Reading

1. Learn Programming – Java Basics. Retrieved from


https://www.tutorialspoint.com/java/index.htm

5.3.3.3 Self-Assessment

Written Assessment
1. Which component is used to compile, debug and execute java program?
a) JVM
b) JDK
c) JIT
d) JRE
2. Which component is responsible to run java programs?
a) JVM
b) JDK
c) JIT
d) JRE
3. Which statement is true about java?
a) Platform independent programming language
b) Platform dependent programming language
239
c) Code dependent programming language
d) Sequence dependent programming language
4. Which of the below is invalid identifier with the main method?
a) public
b) static
c) private
d) final

5. What is the extension of java code files?


a) .class
b) .java
c) .txt
d) .js

Oral Assessment
1. Differentiate between JDE and Eclipse IDE
2. How do you set the Java environment variables?

Practical Assessment
1. Download and install JDE
2. Download, install and launch Eclipse IDE

5.3.3.4 Tools, Equipment, Supplies and Materials


• Computer
• JDK
• Stationery
• Instruction material
• Internet

5.3.3.5 References

https://www.javatpoint.com/java-tutorial

240
5.3.4 Learning outcome 3: Perform Data Operations
5.3.4.1 Learning Activities
Learning Outcome No. 3: Perform Data Operations Special Instructions

Learning Activities Activities may be carried out in groups


or as individual

3.1 Java data types are explained


3.2 Types of statements are explained
3.3 Variables and constants are explained
3.4 Data operations are demonstrated
3.5 Program to perform specified operations is created

5.3.4.2 Information Sheet No 5/LO3: Perform Data Operations

Introduction
This learning outcome covers explaining data types, types of statements, variable and constants,
demonstration of data operations and creating a program to perform a specified operation.

Java Data Types


Variables are nothing but reserved memory locations to store values. This means that when you
create a variable you reserve some space in the memory.

Based on the data type of a variable, the operating system allocates memory and decides what can
be stored in the reserved memory. Therefore, by assigning different data types to variables, you can
store integers, decimals, or characters in these variables.

There are two data types available in Java


● Primitive Data Types
● Reference/Object Data Types

Primitive Data Types


Integer
• int data type is a 32-bit signed two's complement integer.
• Minimum value is - 2,147,483,648 (-2^31)
• Maximum value is 2,147,483,647(inclusive) (2^31 -1)
• Integer is generally used as the default data type for integral values unless there is a concern
about memory.

241
• The default value is 0
• Example: int a = 100000, int b = -200000

Float
• Float data type is a single-precision 32-bit IEEE 754 floating point
• Float is mainly used to save memory in large arrays of floating point numbers
• Default value is 0.0f
• Float data type is never used for precise values such as currency
• Example: float f1 = 234.5

Strings
• A Java string data type is a sequence or string of connected characters (Java char data type
objects). The String is also a class, meaning it has its own methods. These methods include
checking for string length, transforming to upper or lower case, and replacing values in
strings with other value

Boolean
● boolean data type represents one bit of information
● There are only two possible values: true and false
● This data type is used for simple flags that track true/false conditions
● Default value is false
● Example: boolean one = true

Reference Data types


• Reference variables are created using defined constructors of the classes. They are used to
access objects. These variables are declared to be of a specific type that cannot be changed.
For example, Employee, Puppy, etc.
• Class objects and various type of array variables come under reference datatype.
• Default value of any reference variable is null.
• A reference variable can be used to refer any object of the declared type or any compatible
type.
• Example: Animal animal = new Animal("giraffe");

Java statements
Statements are everything that make up a complete unit of execution. For example,
int score = 9*5;

Here, 9*5 is an expression that returns 45, and int score = 9*5; is a statement.

Expression Statements
Some expressions can be made into statement by terminating the expression with a ;. These are
known as expression statements. For example:
number = 10;
242
Here, number = 10 is an expression where as number = 10; is a statement that compiler can execute.
++number;
Here, ++number is an expression where as ++number; is a statement.

Declaration Statements
Declaration statements declares variables. For example,
Double tax = 9.5;

The statement above declares a variable tax which is initialized to 9.5.


Also, there are control flow statements that are used in decision making and looping in Java. You
will learn about control flow statements in later chapters.

Control-flow statements
Control-flow statements determine the order that statements are executed. Typically, Java
statements parse from the top to the bottom of the program. However, with control-flow
statements, that order can be interrupted to implement branching or looping so that the Java
program can run particular sections of code based on certain conditions.

Variables and Constants


• A variable provides us with named storage that our programs can manipulate.
• Each variable in Java has a specific type, which determines the size and layout of the
variable's memory; the range of values that can be stored within that memory; and the
set of operations that can be applied to the variable.

Local Variables
• Local variables are declared in methods, constructors, or blocks.
• Local variables are created when the method, constructor or block is entered and the
variable will be destroyed once it exits the method, constructor, or block.
• Access modifiers cannot be used for local variables.
• Local variables are visible only within the declared method, constructor, or block.
• Local variables are implemented at stack level internally.
• There is no default value for local variables, so local variables should be declared and an
initial value should be assigned before the first use.

Example
Here, age is a local variable. This is defined inside pupAge() method and its scope is limited to only
this method.
public class Test {
public void pupAge() {
int age = 0;
age = age + 7;
System.out.println("Puppy age is : " + age);
243
}

public static void main(String args[]) {


Test test = new Test();
test.pupAge();
}
}
This will produce the following result −

Output
Puppy age is: 7

Class Variables
• Class variables also known as static variables are declared with the static keyword in a class,
but outside a method, constructor or a block.
• There would only be one copy of each class variable per class, regardless of how many
objects are created from it.
• Static variables are rarely used other than being declared as constants. Constants are
variables that are declared as public/private, final, and static. Constant variables never
change from their initial value.
• Static variables are stored in the static memory. It is rare to use static variables other than
declared final and used as either public or private constants.
• Static variables are created when the program starts and destroyed when the program stops.
• Visibility of static variables is similar to instance variables. However, most static variables
are declared public since they must be available for users of the class.
• Default values are same as instance variables. For numbers, the default value is 0; for
Booleans, it is false; and for object references, it is null. Values can be assigned during the
declaration or within the constructor. Additionally, values can be assigned in special static
initializer blocks.
• Static variables can be accessed by calling with the class name ClassName.VariableName.
• When declaring class variables as public static final, then variable names (constants) are all
in upper case. If the static variables are not public and final, the naming syntax is the same
as instance and local variables.

Example
import java.io.*;
public class Employee {
// salary variable is a private static variable
private static double salary;
// DEPARTMENT is a constant
public static final String DEPARTMENT = "Development ";
public static void main(String args[]) {
salary = 1000;
244
System.out.println(DEPARTMENT + "average salary:" + salary);
}
}
This will produce the following result −

Output
Development average salary:1000

Instance Variables
• Instance variables are declared in a class, but outside a method, constructor or any block.
• When a space is allocated for an object in the heap, a slot for each instance variable value is
created.
• Instance variables are created when an object is created with the use of the keyword 'new'
and destroyed when the object is destroyed.
• Instance variables hold values that must be referenced by more than one method, constructor
or block, or essential parts of an object's state that must be present throughout the class.
• Instance variables can be declared in class level before or after use.
• Access modifiers can be given for instance variables.
• The instance variables are visible for all methods, constructors and block in the class.
Normally, it is recommended to make these variables private (access level). However,
visibility for subclasses can be given for these variables with the use of access modifiers.
• Instance variables have default values. For numbers, the default value is 0, for Booleans it is
false, and for object references it is null. Values can be assigned during the declaration or
within the constructor.
• Instance variables can be accessed directly by calling the variable name inside the class.
However, within static methods (when instance variables are given accessibility), they
should be called using the fully qualified name. ObjectReference.VariableName.

Example
import java.io.*;
public class Employee {
// this instance variable is visible for any child class.
public String name;
// salary variable is visible in Employee class only.
private double salary;
// The name variable is assigned in the constructor.
public Employee (String empName) {
name = empName;
}

// The salary variable is assigned a value.


public void setSalary(double empSal) {
salary = empSal;
245
}
// This method prints the employee details.
public void printEmp() {
System.out.println("name : " + name );
System.out.println("salary :" + salary);
}
public static void main(String args[]) {
Employee empOne = new Employee("Ransika");
empOne.setSalary(1000);
empOne.printEmp();
}
}
This will produce the following result −

Output
name : Ransika
salary :1000.0

Constants
Constants are values that do not change during program execution.

Integer Constants
Integer Constants refers to a Sequence of digits which Includes only negative or positive Values and
many other things those are as follows
• An Integer Constant must have at Least one Digit.
• it must not have a Decimal value.
• it could be either positive or Negative.
• if no sign is Specified then it should be treated as Positive.
• No Spaces and Commas are allowed in Name.
Examples: 23. -5600
Real Constants
• A Real Constant must have at Least one Digit.
• it must have a Decimal value.
• it could be either positive or Negative.
• if no sign is Specified then it should be treated as Positive.
• No Spaces and Commas are allowed in Name.
Examples: -76.34,-3

Single Character Constants


● A Character is Single Alphabet a single digit or a Single Symbol that is enclosed within
Single inverted commas.
● ‘S’ ,’1’ etc are Single Character Constant.

246
String Constants
● String is a Sequence of Characters Enclosed between double Quotes These Characters may
be digits , Alphabets Like “Hello” , “1234” etc.

Java Data operations


Variable Assignment
Assigning a value to a variable in Java follows this pattern:
variableName = value ;

Here are three concrete examples which assign values to three different variables with different data
types
myByte = 127;
myFloat = 199.99;
myString = "This is a text";

The first line assigns the byte value 127 to the byte variable named myByte. The second line assigns
the floating point value 199.99 to the floating point variable named myFloat. The third line assigns
the String value (text) this is a text to the String variable named myString.

You can also assign a value to a variable already when it is declared. Here is how that is done:
byte myByte = 127;
float myFloat = 199.99;
String myString = "string value";

Variable Reading
● You can read the value of a Java variable by writing its name anywhere a variable or
constant variable can be used in the code.
● For instance, as the right side of a variable assignment, as parameter to a method call, or
inside a arithmetic expression. For instance:
float myFloat1 = 199.99;
float myFloat2 = myFloat1; // right hand side value in assignment
float myFloat3 = myFloat2 + 123.45; // as part of arithmetic expression
System.out.println(myFloat3); // as parameter in method call.

Variable arithmetic
● We can use arithmetic operators to perform calculations with values in programs.
Arithmetic operators are used in mathematical expressions in the same way that they are
used in algebra.
● A value used on either side of an operator is called an operand. For example, in below
statement the expression 47 + 3, the numbers 47 and 3 are operands.
● The arithmetic operators are examples of binary operators because they require two
operands. The operands of the arithmetic operators must be of a numeric type. You cannot

247
use them on Boolean types, but you can use them on char types, since the char type in Java
is, essentially, a subset of int.

Table 16: Java Arithmetic Operators

Operator Use Description Example


+ x+y Adds x and y float num = 23.4 + 1.6; //
num=25
- x–y Subtracts y from x long n = 12.456 – 2.456; //n=10
-x Arithmetically negates x int i = 10; -i; // i = -10
* x*y Multiplies x by y int m = 10*2; // m=20
/ x/y Divides x by y float div = 20/100 ; // div = 0.2
% x%y Computes the remainder of dividing x int rm = 20/3; // rm = 2
by y
Object Instantiation
In object-oriented programming, an object is an instance of a class. Think of the common
example that is the Employee class; any new employee object used in the program is considered
an instance of that class. Therefore, the fancy term for creating a new instance of that class is
instantiation

Examples
Example 1: Java Program to perform an operation - Calculating Area of a circle
Java program to calculate or to print area of a circle in a simple method
import java.util.Scanner;
class AreaOfCircle
{
public static void main(String args[])
{

Scanner s= new Scanner(System.in);

System.out.println("Enter the radius:");


double r= s.nextDouble();
double area=(22*r*r)/7 ;
System.out.println("Area of Circle is: " + area);
}
}

Output:
Enter the radius :
7
Area of circle : 154.0

248
Step – 1:
import java.util.Scanner;
( Here ‘import’ is a keyword in java used to get features from inbuilt packages. here we using a
package called until it consists of many classes and we using one of the class Scanner to get
command over console which is the interface between user and program. )
Step – 2:
public static void main(Stringargs[])
( The main function, where the execution of program start from here onwards )
Step – 3:
Scanner s= new Scanner(System.in);
(scanner is a class used to scan the input data which was given by the user through a console.
so to get access on a console we want to create an object Syntax:new Scanner(); after creating an
object that reference will store in variable ‘s’ )
Step – 4:
System.out.println("Enter theradius:");
( above code is giving instructions for the user to give the input for radius)
Step – 5:
double r= s.nextDouble();
( here above instruction is get input in the required format. first we want to know about
nextDouble() method it takes a token(collection of symbols divide by white space example:”ABC”,
“DEF” , “GHI”,”10″,”20″) which is given by user.

When user give 10 as input actually in user perspective it is number but any number or string
which entered on console by default those are strings (1o as string) but we want 10 as number
format for that we have method to convert string to number(Int, Double, Float, Long…..)

Some of those method are:


● nextDouble() ,
● nextFloat(),
● nextInt(),
● nextLong()
Step – 6:
double area=(22*r*r)/7 ;
Step – 7: System.out.println(“Area of Circle is: ” + area); ( Once, you entered the radius , the
value stored in a particular function ( nextDouble(); ) and read those values with the help of a
scanner and display the output for a given value.

Example 2: Calculate compound interest


Compound Interest Formula is P (1 + R/n) (nt) - P

● Here P is principal amount.


● R is the annual interest rate.
249
● t is the time the money is invested or borrowed for.
● n is the number of times that interest is compounded per unit t, for example if interest is
compounded monthly and t is in years then the value of n would be 12. If interest is
compounded quarterly and t is in years then the value of n would be 4.

Let’s say an amount of $2,000 is deposited into a bank account as a fixed deposit at an annual
interest rate of 8%, compounded monthly, the compound interest after 5 years would be:
● P = 2000.
● R = 8/100 = 0.08 (decimal).
● n = 12.
● t = 5.

Let’s put these values in the formula.


● Compound Interest = 2000 (1 + 0.08 / 12) (12 * 5) – 2000 = $979.69
● So, the compound interest after 5 years is $979.69
.
Java Program to calculate Compound Interest
In this java program we are calculating the compound interest, we are taking the same example that
we have seen above for the calculation.

public class JavaExample {


public void calculate(int p, int t, double r, int n) {
double amount = p * Math.pow(1 + (r / n), n * t);
double cinterest = amount - p;
System.out.println("Compound Interest after " + t + " years: "+cinterest);
System.out.println("Amount after " + t + " years: "+amount);
}
public static void main(String args[]) {
JavaExample obj = new JavaExample();
obj.calculate(2000, 5, .08, 12);
}
}
Output:
Compound Interest after 5 years: 979.6914166032102
Amount after 5 years: 2979.69141660321

Conclusion
At the end of this learning outcome, the trainee should be able to explain Java data types, types of
statements, variables and constants and demonstrate data operations.

Further Reading
250
https://www.tutorialspoint.com/java/index.htm

5.3.4.3 Self-Assessment

Written Assessment
1. Java has ……...primitive data types.
a)9
b) 8
c) 7
d) 6
2. Which of the following is considered a platform independent code?
a) source code
b) Compiled code

3. Which of the following is the smallest integer data type?


a) bytecode
b) int
c) short
d) long
4. Integer data type does not include following primitive data type.
e) byte
f) short
g) double
h) long
5. What is the size of integer in java programming?
i) 2 byte
j) 3 byte
k) 8 byte
l) 4 byte
Oral Assessment
1. What is an expression statement?
2. What is the difference between class variables and local variables?
3. What are the common java data types?

Practical Assessment
1. Create a java program to calculate the circumference of a circle
.
5.3.4.4 Tools, Equipment, Supplies and Materials

251
• Computer
• JDK
• Stationery
• Instruction material
• Internet

5.3.4.5 References

1. Java Training. Retrieved from https://www.javatpoint.com/java-tutorial

252
5.3.5 Learning outcome 4: Use Control Statements
5.3.5.1 Learning Activities

Learning Outcome No. 4: Use Control Special Instructions


Statements

Learning Activities Activities may be carried out in groups or as


individual

4.1 Control Structures are explained


4.2 Uses of different control statements are
demonstrated
4.3 Programs using control statements are
created

5.3.5.2 Information Sheet No 5/LO4: Use Control Statements

Introduction
This learning outcome covers using control statements. It entails explaining java control
structures, use of different control statements and creating a program using control statements.

Java Control Statements


The JAVA control statements inside a program are usually executed sequentially. Sometimes a
programmer wants to break the normal flow and jump to another statement or execute a set of
statements repeatedly.

The statements which breaks the normal sequential flow of the program are called control
statements.

Control statements enable decision making, looping and branching.

Decision making statements


These statements decides the flow of the execution based on some conditions.
● If then
● If then else
● switch
Looping statements
Statements inside a loop are executed repeatedly provided with some condition which terminates
the loop.
● for
253
● while
● do while

Branching statements
Branching statements are used to jump from the current executing loop.
● break
● continue

Uses of different control statements in Java


Decision making statements
2. If then
The statements under the ‘if’ block are executed only when the condition evaluates to true.
if (condition)
{
//statements
}
Example:
class Great{
public static void main(String args[]){
int a = 10, b = 5;
if(a>b)
{
System.out.println(“a is greater than b”);
}

}
Output:
a is greater than b

Here the value of a is greater than the value of b, thus the statement ‘a is greater than b is
printed. Deciding whether to execute the statement(s) or not, depends upon the condition
specified. Hence it is called as decision making statement.

3. If then else
If then else statement provides two paths. The if block is executed when the condition holds true.
When the condition evaluates to false, the statements inside the else block are executed.

if(condition)
{ //statements, when condition is true
}
else
{
//statements, when condition is false

254
}

Example:
class Great{
public static void main(String args[]){
int a = 10, b = 5;
if(a>b)
{
System.out.println(“a is greater than b”);
}
else
{
System.out.println(“b is greater than a”);

Output:
b is greater than a

In the above program, the statement inside the else block is executed since the
condition a>b evaluates to false.

In the above program, the statement inside the else block is not executed since the
condition a>b evaluates to false.

4. Switch statement
‘switch’ statement can have multiple execution paths. It is similar to that of ‘if else-if’ statement
except that switch can handle expressions which results to any primitive data type and if
statements handle only boolean expressions.

Syntax:
switch (expression)
{
case ‘value1’:
//statements
break;
case ‘value2’:
//statements
break;
case ‘value3’:
//statements
break;

255

default:
//statements
}

The value of the expression is matched with the case values. Only the statements inside the
matched case are executed.

The ‘break’ keyword is added after each case in order to exit from the switch case. If the ‘break’
keyword is not specified, all the cases would be checked and the matching cases would be executed.

The default case is considered when no case value is matched.

Example:
class Number{
public static void main(String args[]){
int n =2;
switch (n)
{case 1:
System.out.println(“One”);
break;
case 2:
System.out.println(“Two”);
break;
case 3:
System.out.println(“Three”);
break;
case 4:
System.out.println(“Four”);
break;
case 5:
System.out.println(“Five”);
break;
default:
System.out.println(“Enter a number within 1 to 5”);
}
}
Output:
TWO

In the above program the value of n decides which statement to be executed. Here it is 2 and hence
the statement inside the case 2 is executed.

256
Looping statements

For

For loop executes a set of statements repeatedly until a specified condition evaluates to false.

Syntax:
For loop has 3 parts
i) Initialization
Executes once, initializes the loop variable which causes the loop to iterate

ii) Condition
the expression which evaluates to true / false. When this condition becomes false, the loop is
terminated.

iii) increment/decrement
Executes at every iteration of the loop, causes the loop variable either to increment or
decrement

Syntax:
for (initialization; condition; increment/decrement)
{
//statements to be repeated
}

Example:
for(int i = 0; i < 5; i++)
{ System.out.println(“Number”+i);
}

Output:
Number:0
Number:1
Number:2
Number:3
Number:4

Note: The 3 parts of the ‘for’ loop can be made optional if necessary. Without them, it becomes an
infinite loop.

While
While loop executes a set of statements repeatedly until a given condition remains true.

257
Syntax:
while(condition)
{ //statements
}
Example:
int i = 5;
while ( i != 0 )
{
System.out.println(“value:”+i);
--i;

Output:
value:5
value:4
value:3
value:2
Value:1
In the above program, the value of i is printed until it is not equal to zero. When the value of i
reaches 0, the execution of the loop is terminated.

do while
Do while loop is similar to that of the while loop except that the condition is evaluated at the end
of the loop in do-while whereas in while loop, it is evaluated before entering into the loop.

Syntax:
do
{
//statements
}while(condition)
The statements given inside the ‘do’ block are executed at least once regardless of the condition.

Example:
int i = 0;
do
{
System.out.println(“value:”+i);
i++;

} while (i<6)

Output:

258
Value: 0
Value: 1
Value: 2
Value: 3
Value: 4
Value: 5

Branching statements
break
When a program executes a break statement, then the loop (for/switch/while/do while) which contains
the break statement is terminated. The flow of the execution jumps to the outside of the loop.
Example:
class Find{
public static void main(String args[]) {
int arr[] = {1,2,3,4,5,6,7};
boolean found = false;
for(int i = 0; i<arr.length; i++)
{ if(arr[i]== 5)
{ found = true;
break;
}
}
if(found)
{System.out.println(“5 is found”);
}

Output:
5 is found

In the above program the for loop iterates over the elements of the array ‘arr’. When the element 5
is present in the array, then a boolean flag ‘found’ is set to true and immediately the for loop is
terminated. Thus the next if block followed by the for loop is executed.

There are two types of break statements


● Labelled break
● Unlabeled break
Unlabeled break is the one explained above.

The difference between the labelled and unlabeled break is that, unlabeled break terminates the
innermost switch, for, while, do while loop which contains the break statement and labeled break
terminates the outer loop which is labeled.

259
Example:
Consider the same example searching an element over a two dimensional array.
class Find{
public static void main(String args[]) {
int arr[][] = {{1,2,3},{4,5,6,}};
boolean found = false;
find:
for(int i = 0; i<arr.length; i++)
{ for(int j=0; j<arr[i].length;j++)
if(arr[i][j] == 5)
{ found = true;
break find; //terminates outer for loop
}
}
if(found)
{System.out.println(“5 is found”);
}
}

Output
5 is found

In this case, the break statement terminates the outermost ‘for’ loop which is labeled.

Continue
Continue statement skips the current iteration of the loop and evaluates the loop’s condition for the
next iteration. Rest of the statements of the loop after the continue statement is not executed and the
next iteration is followed.

The difference between break and continue is that continue statement breaks the current iteration of
the loop whereas break statement terminates the loop itself.

Example:
public class ContinueExample {
public static void main(String a[]){
for(int i=1;i<=10;i++){
if(i%2 == 0){
continue;
}
System.out.println(i);
}
}

260
}

Output
1
3
5
7
9

In the above program, whenever the value of i is divisible by 2 (even number) the current
iteration is ignored printing just the odd numbers alone.

Conclusion
At the end of this learning outcome, the trainee should be able to explain control statements
explained, demonstrate different control statements and create programs using statements.

Further Reading

Schildt, H(2019 ) . Java A Beginner’s Guide (8th ed.). McGrawHill


Education

5.3.5.3 Self Assessment

Written Assessment
1. Which of these are selection statements in Java?
a) if()
b) for()
c) continue
d) break
2. Which of the following loops will execute the body of loop even when condition controlling
the loop is initially false?
a) do-while
b) while
c) for
d) none of the mentioned
3. Which of these jump statements can skip processing the remainder of the code in its body
for a particular iteration?
a) break
b) return
c) exit
261
d) continue
4. Which of this statement is incorrect?
a) switch statement is more efficient than a set of nested ifs
b) two case constants in the same switch can have identical values
c) switch statement can only test for equality, whereas if statement can evaluate any type of
boolean expression
d) it is possible to create a nested switch statements
5. Which of these selection statements test only for equality?
a) if
b) switch
c) if & switch
d) none of the mentioned
Oral Assessment
1. What are the common java looping statements?
2. What do you understand by branching statements?
3. What are java decision making statements? Give examples
4. In what situation can the if then else statement be used?

Practical Assessment
1. Create a java program using the following decision making controls
• if then - to display whether a person is an adult or not depending on the age
• switch – To display a message informing the user the number/she has entered e.g.
“Nine” upon entering the number 9 when prompted in the program.
2. Create a java program using both the for and the while loops to display odd numbers from
20 to 10 in descending order.
5.3.5.4 Tools, Equipment, Supplies and Materials
• Computer
• JDK
• Stationery
• Instruction material
• Internet

5.3.5.5 References

https://www.edureka.co/blog/control-statements-in-java/

262
5.3.6 Learning Outcome 5: Use Methods
5.3.6.1 Learning Activities
Learning Outcome No. 5: Use Methods Special Instructions

Learning Activities Activities may be carried out in groups or as


individual
1.1 Procedures/Functions/Methods are explained
1.2 Methods are demonstrated
1.3 Programs using methods are created

5.3.6.2 Information Sheet No 5/LO5: Use Methods

Introduction
This learning outcome covers using methods. It entails explaining java procedures/methods/
functions, demonstrating methods and creating programs using methods.

Java Methods
Definition
A Java method is a collection of statements that are grouped together to perform an operation.
When you call the System.out.println() method, for example, the system actually executes several
statements in order to display a message on the console.

Structure of a method
Syntax: Method definition consists of a method header and a method body.
modifier returnType nameOfMethod (Parameter List) {
// method body
}
• modifier − It defines the access type of the method and it is optional to use.
• returnType − Method may return a value.
• nameOfMethod − This is the method name. The method signature consists of the method
name and the parameter list.
• Parameter List − The list of parameters, it is the type, order, and number of parameters of a
method. These are optional, method may contain zero parameters.
• method body − The method body defines what the method does with the statements.

Example:
public static int methodName(int a, int b) {
263
// body
}
Here,
• public static − modifier
• int − return type
• methodName − name of the method
• a, b − formal parameters
• int a, int b − list of parameters

Method Definition Example:


Below is a method called minFunction(). This method takes two parameters num1 and num2 and
returns the maximum between the two –

public static int minFunction(int n1, int n2) {


int min;
if (n1 > n2)
min = n2;
else
min = n1;
return min;
}

Method calling
To use or apply a method, it should be called. There are two ways in which a method is called i.e.
method returns a value or returning nothing (no return value).

When a program invokes a method, the program control gets transferred to the called method.
This called method then returns control to the caller in two conditions, when −
o the return statement is executed.
o it reaches the method ending closing brace.

Methods returning void is considered as a call to a statement. For example:


System.out.println("This is Me!");

The method returning value can be understood by the example:


int result = sum(6, 9);

Program Example:
public class ExampleMinNumber {
public static void main(String[] args) {
int a = 11;
int b = 6;
int c = minFunction(a, b);

264
System.out.println("Minimum Value = " + c);
}

/* returns the minimum of two numbers */


public static int minFunction(int n1, int n2) {
int min;
if (n1 > n2)
min = n2;
else
min = n1;
return min;
}
}

Output:
Minimum value = 6

Void keyword
The void keyword allows us to create methods which do not return a value. Here, in the following
example we're considering a void method methodRankPoints. This method is a void method,
which does not return any value.

Call to a void method must be a statement i.e. methodRankPoints(255.7);. It is a Java statement


which ends with a semicolon as shown in the following example.

Program Example:
public class ExampleVoid {
public static void main(String[] args) {
methodRankPoints(255.7);
}

public static void methodRankPoints(double points) {


if (points >= 202.5) {
System.out.println("Rank:A1");
}else if (points >= 122.4) {
System.out.println("Rank:A2");
}else {
System.out.println("Rank:A3");
}
}
}
Output:
Rank:A1

265
Passing parameters by value
During a method call, arguments should be passed in the same order as their respective
parameters in the method specification. Parameters can be passed by value or by reference.

Passing Parameters by Value means calling a method with a parameter. Through this, the
argument value is passed to the parameter.

Example:
The following program shows an example of passing parameter by value. The values of the
arguments remain the same even after the method invocation.

public class swappingExample {

public static void main(String[] args) {


int a = 30;
int b = 45;
System.out.println("Before swapping, a = " + a + " and b = " + b);

// Invoke the swap method


swapFunction(a, b);
System.out.println("\n**Now, Before and After swapping values will be same here**:");
System.out.println("After swapping, a = " + a + " and b is " + b);
}
public static void swapFunction(int a, int b) {
System.out.println("Before swapping(Inside), a = " + a + " b = " + b);
// Swap n1 with n2
int c = a;
a = b;
b = c;
System.out.println("After swapping(Inside), a = " + a + " b = " + b);
}
}
Output:
Before swapping, a = 30 and b = 45
Before swapping(Inside), a = 30 b = 45
After swapping(Inside), a = 45 b = 30
**Now, Before and After swapping values will be same here**:
After swapping, a = 30 and b is 45

Method overloading

266
When a class has two or more methods by the same name but different parameters, it is known as
method overloading. It is different from overriding. In overriding, a method has the same method
name, type, number of parameters, etc.

Let’s consider the example discussed earlier for finding minimum numbers of integer type. If,
let’s say we want to find the minimum number of double type. Then the concept of overloading
will be introduced to create two or more methods with the same name but different parameters.

The following example explains the same:


Example:
public class ExampleOverloading {
public static void main(String[] args) {
int a = 11;
int b = 6;
double c = 7.3;
double d = 9.4;
int result1 = minFunction(a, b);

// same function name with different parameters


double result2 = minFunction(c, d);
System.out.println("Minimum Value = " + result1);
System.out.println("Minimum Value = " + result2);
}

// for integer
public static int minFunction(int n1, int n2) {
int min;
if (n1 > n2)
min = n2;
else
min = n1;
return min;
}

// for double
public static double minFunction(double n1, double n2) {
double min;
if (n1 > n2)
min = n2;
else
min = n1;
return min;
}

267
}

Output
Minimum Value = 6
Minimum Value = 7.3

“this” keyword
“this” is a keyword in Java which is used as a reference to the object of the current class, with in
an instance method or a constructor. Using this you can refer the members of a class such as
constructors, variables and methods.

Note − The keyword this is used only within instance methods or constructors

In general, the keyword this is used to differentiate the instance variables from local variables if
they have same names, within a constructor or a method.

Example:
Here is an example that uses this keyword to access the members of a class

public class This_Example {


// Instance variable num
int num = 10;
This_Example() {
System.out.println("This is an example program on keyword this");
}
This_Example(int num) {
// Invoking the default constructor
this();
// Assigning the local variable num to the instance variable num
this.num = num;
}
public void greet() {
System.out.println("Hi Welcome to Java tutorial");
}
public void print() {
// Local variable num
int num = 20;
// Printing the local variable
System.out.println("value of local variable num is : "+num);
// Printing the instance variable
System.out.println("value of instance variable num is : "+this.num);
// Invoking the greet method of a class
this.greet();

268
}
public static void main(String[] args) {
// Instantiating the class
This_Example obj1 = new This_Example();
// Invoking the print method
obj1.print();
// Passing a new value to the num variable through parametrized constructor
This_Example obj2 = new This_Example(30);
// Invoking the print method again
obj2.print();
}
}

Output
This is an example program on keyword this
value of local variable num is : 20
value of instance variable num is : 10
Hi Welcome to Java tutorial
This is an example program on keyword this
value of local variable num is : 20
value of instance variable num is : 30
Hi Welcome to Java tutorial

Variable arguments
JDK 1.5 enables you to pass a variable number of arguments of the same type to a method. The
parameter in the method is declared as follows
typeName... parameterName

In the method declaration, you specify the type followed by an ellipsis (...). Only one variable-
length parameter may be specified in a method, and this parameter must be the last parameter.
Any regular parameters must precede it.

Example:
public class VarargsDemo {
public static void main(String args[]) {
// Call method with variable args
printMax(34, 3, 3, 2, 56.5);
printMax(new double[]{1, 2, 3});
}
public static void printMax( double... numbers) {
if (numbers.length == 0) {
System.out.println("No argument passed");
return;

269
}
double result = numbers[0];
for (int i = 1; i < numbers.length; i++)
if (numbers[i] > result)
result = numbers[i];
System.out.println("The max value is " + result);
}
}
Output:
The max value is 56.5
The max value is 3.0

Conclusion
At the end of this learning outcome, the trainee should be able to explain
methods/procedures/functions, demonstrate methods and create programs using methods.

Further Reading

Schildt, H(2019 ) . Java A Beginner’s Guide (8th ed.). McGrawHill Education

5.3.6.3 Self-Assessment

Written Assessment
1. What is the process of defining more than one method in a class differentiated by method
signature?
a) Function overriding
b) Function overloading
c) Function doubling
d) None of the mentioned
2. Which of the following is a method having same name as that of its class?
a) finalize
b) delete
c) class
d) constructor
3. Which method can be defined only once in a program?
a) main method
b) finalize method
c) static method
d) private method

270
4. Which of this statement is incorrect?
a) All object of a class are allotted memory for the all the variables defined in the class
b) If a function is defined public it can be accessed by object of other class by inheritation
c) main() method must be made public
d) All object of a class are allotted memory for the methods defined in the class
5. What is the return type of a method that does not return any value?
a) int
b) float
c) void
d) double
Oral Assessment
1. What do you understand by java methods?
2. Which is the best way to call a java method in a java program?
3. What is method overloading?
4. What do you understand by the keyword void?
Practical Assessment
1. Create a java method ComputeInterest that calculate and returns the simple interest I
earned from a principal amount P at a rate R over a period of time N (years)
2. Write a program that calls the above method using user entered parameters for principal,
rate and time and displays the Interest earned.
5.3.6.4 Tools, Equipment, Supplies and Materials
• Computer
• JDK
• Stationery
• Instruction material
• Internet

5.3.6.5 References

1. Java – Methods. Retrieved from https://www.tutorialspoint.com/java


2. Methods in Java. Retrieved from https://www.javatpoint.com

271
5.3.7 Learning Outcome 6: Understand Object Oriented Programming
5.3.7.1 Learning Activities
Learning Outcome No. 6: Understand Object Special Instructions
Oriented Programming

Learning Activities Activities may be carried out in groups or as


individual
6.1 Object oriented programming is explained
6.2 Classes and objects are explained
6.3 Classes and objects are demonstrated.
6.4 Inheritance is demonstrated
6.5 Inheritance programs are developed

5.3.7.2 Information Sheet No 5/LO6: Understand Object Oriented Programming

Introduction

This learning outcome covers explaining the Object oriented programming concept, java classes
and objects. It also includes demonstrating classes, objects and inheritance and developing
inheritance programs.

What is Object Oriented Programming (OOP)?


• Object means a real-world entity such as a pen, chair, table, computer, watch, etc. Object-
Oriented Programming is a methodology or paradigm to design a program using classes and
objects.
• The popular object-oriented languages are Java, C#, PHP, Python, C++, etc.
• OOP simplifies software development and maintenance by providing some concepts:
o Object
o Class
o Inheritance
o Polymorphism
o Abstraction
o Encapsulation

Object oriented programming concepts


Class
Collection of objects is called class. It is a logical entity.
A class can also be defined as a blueprint from which you can create an individual object. Class
doesn't consume any space

Object
272
Any entity that has state and behavior is known as an object. For example, a chair, pen, table,
keyboard, bike, etc. It can be physical or logical.

An Object can be defined as an instance of a class. An object contains an address and takes up some
space in memory. Objects can communicate without knowing the details of each other's data or
code. The only necessary thing is the type of message accepted and the type of response returned by
the objects.

Example: A dog is an object because it has states like color, name, breed, etc. as well as behaviors
like wagging the tail, barking, eating, etc.

Inheritance
When one object acquires all the properties and behaviors of a parent object, it is known as
inheritance. It provides code reusability.

Polymorphism
If one task is performed in different ways, it is known as polymorphism. For example: to draw
something, for example, shape, triangle, rectangle, etc.

Another example can be to speak something; for example, a cat speaks meow, dog barks woof, etc.

Abstraction
Hiding internal details and showing functionality is known as abstraction. For example phone call,
we don't know the internal processing.
In Java, we use abstract class and interface to achieve abstraction.

Encapsulation
Binding (or wrapping) code and data together into a single unit are known as encapsulation. For
example, a capsule, it is wrapped with different medicines.
A java class is the example of encapsulation. Java bean is the fully encapsulated class because all
the data members are private here.

Creating Classes
A class consists of attributes and methods

Declaring attributes
Attribute An attribute is another term for a field. It’s typically a public field that can be accessed
directly.

Class attributes are variables within a class.

Example:
Class called “MyClass” with two attributes: x and y:

273
public class MyClass {
int x = 5;
int y = 3;
}

Creating Methods
As explained earlier, A Java method is a collection of statements that are grouped together to perform
an operation. Methods in a class are usually declared as public in order for them to be accessed by
objects from outside the class (within the main function).

Example: The following class defines three variables and one method called Findvolume:

class Box{
double width;
double height;
double depth;

//Findvolume method
public void Findvolume(){
System.out.println("Volume is " + width*height*depth);
}
}

Creating objects
A class provides the blueprints for objects. So basically, an object is created from a class. In Java,
the new keyword is used to create new objects.

There are three steps when creating an object from a class −


• Declaration − A variable declaration with a variable name with an object type.
• Instantiation − The 'new' keyword is used to create the object.
• Initialization − The 'new' keyword is followed by a call to a constructor. This call initializes
the new object.

Example:
To use the above class, we must create an object of its type. The following program does that and
then uses the class variables and the method defined in the class.

//First define the class


class Box{
double width;
double height;
double depth;
274
public void Findvolume(){
System.out.println("Volume is " + width*height*depth);
}
}

class BoxDemo{
public static void main(String[] args){
Box myBox=new Box();
//assign values
myBox.width=10; //call the variables
myBox.height=20;
myBox.depth=15;
//display volume
myBox.Findvolume(); //call the method
}
}

Inheritance
Inheritance can be defined as the process where one class acquires the properties (methods and fields)
of another. With the use of inheritance the information is made manageable in a hierarchical order.

The class which inherits the properties of other is known as subclass (derived class, child class) and
the class whose properties are inherited is known as superclass (base class, parent class).

extends Keyword
extends is the keyword used to inherit the properties of a class.
Syntax
class Super {
.....
.....
}
class Sub extends Super {
.....
.....
}

Example 1: My_Calculation.java
Following is an example demonstrating Java inheritance. In this example, you can observe two classes
namely Calculation and My_Calculation.

275
Using extends keyword, the My_Calculation inherits the methods addition() and Subtraction() of
Calculation class.

class Calculation {
int z;
public void addition(int x, int y) {
z = x + y;
System.out.println("The sum of the given numbers:"+z);
}

public void Subtraction(int x, int y) {


z = x - y;
System.out.println("The difference between the given numbers:"+z);
}
}

public class My_Calculation extends Calculation {


public void multiplication(int x, int y) {
z = x * y;
System.out.println("The product of the given numbers:"+z);
}

public static void main(String args[]) {


int a = 20, b = 10;
My_Calculation demo = new My_Calculation();
demo.addition(a, b);
demo.Subtraction(a, b);
demo.multiplication(a, b);
}
}
Compile and execute the above code as shown below.
javac My_Calculation.java
java My_Calculation

Output:
The sum of the given numbers:30
The difference between the given numbers:10
The product of the given numbers:200

In the given program, when an object to My_Calculation class is created, a copy of the contents
of the superclass is made within it. That is why, using the object of the subclass you can access the
members of a superclass.

276
The Superclass reference variable can hold the subclass object, but using that variable you can
access only the members of the superclass, so to access the members of both classes it is
recommended to always create reference variable to the subclass.
If you consider the above program, you can instantiate the class as given below. But using the
superclass reference variable ( cal in this case) you cannot call the method multiplication(), which
belongs to the subclass My_Calculation.
Calculation demo = new My_Calculation();
demo.addition(a, b);
demo.Subtraction(a, b);
Note − A subclass inherits all the members (fields, methods, and nested
classes) from its superclass. Constructors are not members, so they are not
inherited by subclasses, but the constructor of the superclass can be invoked
from the subclass.

Example 2: Car.java
class Vehicle {
protected String brand = "Ford"; // Vehicle attribute
public void honk() { // Vehicle method
System.out.println("Tuut, tuut!");
}
}

class Car extends Vehicle {


private String modelName = "Mustang"; // Car attribute
public static void main(String[] args) {
// Create a myCar object
Car myCar = new Car();
// Call the honk() method (from the Vehicle class) on the myCar object
myCar.honk();
// Display the value of the brand attribute (from the Vehicle class) and the value of the
modelName from the Car class
System.out.println(myCar.brand + " " + myCar.modelName);
}
}
Conclusion
At the end of this learning outcome, the trainee should be able to explain object oriented
programming, classes and objects, demonstrate classes, objects and inheritance and develop
inheritance programs.

Further Reading

277
Schildt, H(2019 ) . Java A Beginner’s Guide (8th ed.). McGraw-Hill Education
5.3.7.4 Self Assessment

Written Assessment
1. What is the difference between a class and an object?
2. What is the meaning of polymorphism
3. How are the concepts of encapsulation and a class related?
4. Why is the OOP style popular?
5. What is the key advantage of the inheritance concept?

Oral Assessment
• Describe how the inheritance concept can be used to easily capture data of different
categories of employees in an organisation.

Practical Assessment
1. Create a class Circle that has radius as the attribute and also contains a method to
ComputeArea to calculate the areas of a circle
2. Implement the above class in a program that you can test.

5.3.7.4 Tools, Equipment, Supplies and Materials


• Computer
• JDK
• Stationery
• Instruction material
• Internet
5.3.7.5 References

1. Java – Object Oriented – Retrieved from https://www.tutorialspoint.com/java


2. Objects and class. Retrieved from https://www.javatpoint.com/object-and-class-in-java

278
CHAPTER 6: DATABASE MANAGEMENT SKILLS
6.1 Introduction
This unit covers the competencies required to demonstrate database management skills. It involves
understanding database fundamentals, designing a database, using Structured Query Language,
understanding the design of object oriented databases, understanding indexing and hashing and
understanding database applications.

6.2 Performance Standard


1. Installed MS SQL server
2. Created an entity relationship model
3. Normalized database tables
4. Validated an ER model
5. Created and queried a database from a validated ER model.
6. Retrieved data from several tables using joins
7. Prescribed a database type based on user requirements.
8. Demonstrated Object Oriented Concepts
9. Demonstrated designing of views and triggers in object oriented databases.
10. Implemented Indexing and hashing

6.3 Learning Outcomes


6.3.1 List of Learning Outcomes
1. Understand database fundamentals
2. Design a data base
3. Use Structured Query Language
4. Design of object oriented database
5. Understand indexing and hashing
6. Understand database applications

279
6.3.2 Learning Outcome 1: Understand database fundamentals
6.3.2.1 Learning Activities
Learning Outcome 1: Understand database fundamentals
Learning Activities Special Instructions

1.1 A database is defined Activities may be carried out in


1.2 Terminologies used with databases are explained groups or as individual
1.3 Reasons of using databases are explained
1.4 Relational Model is defined
1.5 Key concepts in relational modelling are explained
1.6 Properties of a table/relation are explained
1.7 Relational Database Management Systems (RDBMSs)
products are compared
1.8 Installation of MS SQL server is demonstrated
1.9 MS SQL server interface is explained
1.10 Properties of MS SQL server database are explained

6.3.2.2 Information Sheet No 6:LO1: Understand database fundaments


Introduction

This learning outcome covers the definition of database, relational model and other terminologies
used in databases. It also explains the reasons for using databases, key concepts in relational
modelling, properties of tables and the MS SQL server interface. It also involves comparing relational
database management systems, demonstrating MS SQL server installation and explaining MS SQL
server database properties.

Database
A Database is a collection of related data organised in a way that data can be easily accessed,
managed and updated. Database can be software based or hardware based, with one sole purpose,
storing data

Figure 59: MSAccess Database Sample

280
Database terminologies

✓ Table
A database table is composed of records and fields that hold data. Tables are also called datasheets.
Each table in a database holds data about a different, but related, subject.

Figure 60:: MSAccess Table Sample

✓ Database engine

A database engine (or storage engine) is the underlying software component that a database
management system (DBMS) uses to create, read, update and delete (CRUD) data from a database.
... The term "database engine" is frequently used interchangeably with "database server" or
"database management system".

✓ Records
Data is stored in records. A record is composed of fields and contains all the data about one
particular person, company, or item in a database. In this database, a record contains the data for
one customer support incident report. Records appear as rows in the database table. A record for
Log ID 1201242 is highlighted in below.

Figure 61: : MSAccess Table Records Sample

✓ Field
A field is part of a record and contains a single piece of data for the subject of the record. In the
database table illustrated in Figure below, each record contains four fields:
Log ID A number assigned to this customer support incident for
identification purposes
Operator The code for the customer support operator who handled
this incident
Resolved A check box to indicate whether the incident was resolved
Duration The time in seconds the operator spent on this incident
281
Fields appear as columns in a database table. Data from the Log ID field for five records is
highlighted in the Figure below.

Figure 62:: MSAccess Table Fields Sample.

Reasons of using databases


The various reasons a database is important are:
Manages large amounts of data
A database stores and manages a large amount of data on a daily basis. This would not be
possible using any other tool such as a spreadsheet as they would simply not work.

Accurate
A database is pretty accurate as it has all sorts of build in constraints, checks etc. This means
that the information available in a database is guaranteed to be correct in most cases.

Easy to update data


In a database, it is easy to update data using various Data Manipulation languages (DML)
available. One of these languages is SQL.

Security of data
Databases have various methods to ensure security of data. There are user logins required
before accessing a database and various access specifiers. These allow only authorised users
to access the database.

Data integrity
This is ensured in databases by using various constraints for data. Data integrity in databases
makes sure that the data is accurate and consistent in a database.

Easy to research data


It is very easy to access and research data in a database. This is done using Data Query
Languages (DQL) which allow searching of any data in the database and performing
computations on it.

Control of data redundancy


In the database approach, ideally, each data item is stored in only one place in the database.
In some cases, data redundancy still exists to improve system performance, but such

282
redundancy is controlled by application programming and kept to minimum by introducing
as little redundancy as possible when designing the database.

Data sharing
The integration of all the data, for an organization, within a database system has many
advantages. First, it allows for data sharing among employees and others who have access to the
system. Second, it gives users the ability to generate more information from a given amount of
data than would be possible without the integration.

Data independence
Another advantage of a database management system is how it allows for data independence. In
other words, the system data descriptions or data describing data (metadata) are separated from
the application programs. This is possible because changes to the data structure are handled by
the database management system and are not embedded in the program itself.

Backup and recovery facilities


Backup and recovery are methods that allow you to protect your data from loss. The
database system provides a separate process, from that of a network backup, for backing up
and recovering data. If a hard drive fails and the database stored on the hard drive is not
accessible, the only way to recover the database is from a backup.

Support for multiple views of data


A database supports multiple views of data. A view is a subset of the database, which is
defined and dedicated for particular users of the system. Multiple users in the system might
have different views of the system. Each view might contain only the data of interest to a
user or group of users.

Insulation between program and data


In the file-based system, the structure of the data files is defined in the application programs
so if a user wants to change the structure of a file, all the programs that access that file might
need to be changed as well. On the other hand, in the database approach, the data structure is
stored in the system catalogue and not in the programs. Therefore, one change is all that is
needed to change the structure of a file. This insulation between the programs and data is
also called program-data independence.

Relational model
The relational model represents the database as a collection of relations. A relation is
nothing but a table of values. In this model, data is organised in two-dimensional tables and
the relationship is maintained by storing a common field.
.

Relational Modeling Concepts

283
✓ Relations/tables
A relational database system contains one or more objects called tables or relations. The data or
information for the database are stored in these tables. Tables are uniquely identified by their names
and are comprised of columns and rows. Columns contain the column name, data type, and any
other attributes for the column. Rows contain the records or data for the columns. Here is a sample
table called "weather". City, state, high, and low are the columns. The rows contain the data for
this table:

Weather
city state high low
Phoenix Arizona 105 90
Tucson Arizona 101 92
Flagstaff Arizona 88 69
San Diego California 77 60
New
Albuquerque 80 72
Mexico
Table Weather

✓ Attributes/Columns
Each named column in a Table is an attribute. Attributes are the properties which define a relation.
e.g., Student_Rollno, NAME, etc.

✓ Domain
A domain is the original sets of atomic values used to model data. By atomic value, we mean that
each value in the domain is indivisible as far as the relational model is concerned. For example:
• The domain of Marital Status has a set of possibilities: Married, Single, Divorced.
• The domain of Shift has the set of all possible days: {Mon, Tue, Wed…}.
• The domain of Salary is the set of all floating-point numbers greater than 0 and less than
200,000.
• The domain of First Name is the set of character strings that represents names of people.
In summary, a domain is a set of acceptable values that a column is allowed to contain. This is
based on various properties and the data type for the column. We will discuss data types in another
chapter.

✓ Tuples/Rows
A row—also called a tuple—represents a single, implicitly structured data item in a table. Each
row in a table represents a set of related data, and every row in the table has the same structure.

✓ Primary Key

284
A primary key is a field in a table which uniquely identifies each row/record in a database table.
Primary keys must contain unique values. A primary key column cannot have NULL values. A
table can have only one primary key, which may consist of single or multiple fields.
.
Example:
Employee ID FirstName LastName
11 Andrew Johnson
22 Tom Wood
33 Alex Hale
Demonstration of a Primary Key

In the above-given example, employee ID is a primary key because it uniquely identifies an


employee record. In this table, no other employee can have the same employee ID.
✓ Foreign Key
A FOREIGN KEY is a key used to link two tables together.
A FOREIGN KEY is a field (or collection of fields) in one table that refers to the PRIMARY KEY
in another table. The table containing the foreign key is called the child table, and the table
containing the candidate key is called the referenced or parent table.
Look at the following two tables:

"Persons" table:
Persons table
PersonID LastName FirstName Age
1 Hansen Ola 30
2 Svendson Tove 23
3 Pettersen Kari 20

"Orders" table:
Orders table
OrderID OrderNumber PersonID
1 77895 3
2 44678 3
3 22456 2
4 24562 1
• Notice that the "PersonID" column in the "Orders" table points to the "PersonID" column in
the "Persons" table.
• The "PersonID" column in the "Persons" table is the PRIMARY KEY in the "Persons"
table.
• The "PersonID" column in the "Orders" table is a FOREIGN KEY in the "Orders" table.
• The FOREIGN KEY constraint is used to prevent actions that would destroy links between
tables.
• The FOREIGN KEY constraint also prevents invalid data from being inserted into the
foreign key column, because it has to be one of the values contained in the table it points to.

285
Properties of a relation/table

Relational tables have six properties:


Values Are Atomic
This property implies that columns in a relational table are not repeating group or arrays. Such
tables are referred to as being in the "first normal form" (1NF). The atomic value property of
relational tables is important because it is one of the cornerstones of the relational model.
The key benefit of the one value property is that it simplifies data manipulation logic.

Column Values Are of the Same Kind


In relational terms this means that all values in a column come from the same domain. A domain
is a set of values which a column may have. For example, a Monthly_Salary column contains only
specific monthly salaries. It never contains other information such as comments, status flags, or
even weekly salary.
This property simplifies data access because developers and users can be certain of the type of data
contained in a given column. It also simplifies data validation. Because all values are from the same
domain, the domain can be defined and enforced with the Data Definition Language (DDL) of the
database software.

Each Row is Unique


This property ensures that no two rows in a relational table are identical; there is at least one
column, or set of columns, the values of which uniquely identify each row in the table. Such
columns are called primary keys.
This property guarantees that every row in a relational table is meaningful and that a specific row
can be identified by specifying the primary key value.

e Sequence of Columns is Insignificant


This property states that the ordering of the columns in the relational table has no meaning.
Columns can be retrieved in any order and in various sequences. The benefit of this property is that
it enables many users to share the same table without concern of how the table is organized. It also
permits the physical structure of the database to change without affecting the relational tables.

The Sequence of Rows is Insignificant


This property is analogous the one above but applies to rows instead of columns. The main benefit
is that the rows of a relational table can be retrieved in different order and sequences. Adding
information to a relational table is simplified and does not affect existing queries.

Each Column Has a Unique Name


Because the sequence of columns is insignificant, columns must be referenced by name and not by
position. In general, a column name need not be unique within an entire database but only within
the table to which it belongs.

Comparison of RDBMS products

286
✓ Oracle
Oracle Corporation owns Oracle Database, and the code is not open sourced.

Oracle DB is for large applications, particularly in the banking industry. Most of the world’s top
banks run Oracle applications because Oracle offers a powerful combination of technology and
comprehensive, pre-integrated business applications, including essential functionality built
specifically for banks.

The main disadvantage of using Oracle is that it is not free to use like its open source competitors
and can be quite expensive.

✓ MS SQL server
Microsoft owns SQL Server. Like Oracle DB, the code is close sourced. Large enterprise
applications mostly use SQL Server.

Microsoft offers a free entry-level version called Express but can become very expensive as you
scale your application.

✓ My SQL
MySQL is the most popular open source SQL database. It is typically used for web application
development, and often accessed using PHP.

The main advantages of MySQL are that it is easy to use, inexpensive, reliable (has been around
since 1995), and has a large community of developers who can help answer questions.

Some of the disadvantages are that it has been known to suffer from poor performance when
scaling, open source development has lagged since Oracle has taken control of MySQL, and it does
not include some advanced features that developers may be used to
.
✓ Ms Access
Microsoft Access is a Database Management System offered by Microsoft. It uses the Microsoft Jet
Database Engine and comes as a part of the Microsoft Office suite of application.
Microsoft Access offers the functionality of a database and the programming capabilities to create
easy to navigate screens (forms)

Installation of MS SQL server


Beginning with SQL Server 2016 (13.x), SQL Server is only available as a 64-bit application. Here
are important details about how to get SQL Server and how to install it.

Editions and features: Review the supported features for the different editions and versions of
SQL Server to determine which best suits your business needs.
• SQL Server 2019 (15.x).
• SQL Server 2017 (14.x).
• SQL Server 2016 (13.x).
287
• SQL Server 2014 (12.x)
Requirements: Review installation requirements, system configuration checks, and security
considerations in Planning a SQL Server Installation

Install SQL Server 2017 Developer Edition


To install SQL Server, you need to download it from the Microsoft.com website via the following
link: https://www.microsoft.com/en-us/sql-server/sql-server-2017
Once the download completes, you double-click the file SQLServer2017-SS