Computer Science Level 6 Learning Guide
Computer Science Level 6 Learning Guide
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.
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.
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
iv
ACRONYMS
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
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
xiv
CHAPTER 1: INTRODUCTION
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.
• 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:
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.
4
2.3.2 Learning Outcome 1: Understand Principles of Computer Organization and Design
2.3.2.1 Learning Activities
Introduction
This learning outcome covers defining computer organisation, explaining and structure and
function of computer components and identifying hardware components.
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
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.
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
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.
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:
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.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
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
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.
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.
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.
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.
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.
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.
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.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
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.
• 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.
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.
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
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.
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)
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.
ROM chips are not only used in the computer but also in other electronic items like washing
machine and microwave oven.
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
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
Expense Primary memory is costlier than Secondary memory is cheaper than primary
secondary memory. memory.
Storage Devices
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.
Following are the important differences between Cache Memory and Virtual 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.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
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.
• Bus: A bus is a subsystem that transfers data between computer components inside a
computer or between computers
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.
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.
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.
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
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: 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.
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.
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.
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.
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.
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.
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.
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.
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.
Interrupt Processing
44
Figure 25:Interrupt Processing
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.
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.
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.
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
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.
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
In any binary number, the rightmost digit is called least significant bit (LSB) and leftmost digit is
called 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 –
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
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
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 –
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.
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:
Decimal to Hexadecimal
Decimal numbers can be converted to octal by repeated division of the number by 16 while
recording the remainder.
Example:
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.
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.
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.
Addition
Example on decimal value given in scientific notation:
3.25 x 10 ** 3
+ 2.63 x 10 ** -1
-----------------
First step: Align decimal points
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)
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.
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.
Multiplication
Example on decimal values given in scientific notation:
3.0 x 10 ** 1
+ 0.5 x 10 ** 2
-----------------
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.
1 01000001 10.00110000
becomes
1 01000010 1.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.
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.
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
Example:
1.23 If 2 decimal places, 1.3
-2.86 if 2 decimal places, -2.8
Example:
1.23 If 2 decimal places, 1.2
60
-2.86 if 2 decimal places, -2.9
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
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
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.
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.
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).
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.)
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).
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).
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.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.
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
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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 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.
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.
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.
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.
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.
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.
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.
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.
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.
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>
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
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.5 References
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
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.
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
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.
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
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.
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 −
The PCB is maintained for a process throughout its lifetime, and is deleted once the process
terminates.
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.
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.
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.
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
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.
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.
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.
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.
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.
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
P0 0 5 0
P1 1 3 5
P2 2 8 14
P3 3 6 8
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
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
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
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.
P0 (0 - 0) + (12 - 3) = 9
P1 (3 - 1) = 2
P3 (9 - 3) + (17 - 12) = 11
Average Wait Time: (9+2+12+11) / 4 = 8.5
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.
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.
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.
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.
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.
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.
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.
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
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
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.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
Introduction
This learning outcome covers memory management. It entails explaining management, explaining
memory management techniques and demonstrating virtual memory settings.
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.
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.
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
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.
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.
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.
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.
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 −
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.
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.
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.
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.
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:
This example sets the paging file to "9216" and "12288" megabytes for the initial and maxium size:
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.5 References
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
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 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.
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.
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.
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.
• 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.
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.
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.
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.
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.
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 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.
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.
Disk Management can also be started by executing diskmgmt.msc via the Command Prompt or
another command-line interface in Windows.
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.
1. Open Disk Management, the tool included in all versions of Windows that lets you partition
drives, among a number of other things.
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.
7. Choose Next > on the Specify Volume Size step to confirm the size of the drive you're creating.
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?"
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.
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.
8. Windows is usually pretty good about warning you before you might do something damaging,
and a hard drive format is no exception.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
IMPORTANT: Windows Device Manager doesn’t always detect outdated drivers. So you
can’t assume all your drivers are up to date
(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.
153
6. Select Search automatically for updated driver software.
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.
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.
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
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.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
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.
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.
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.
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.
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.
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:
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.
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.
163
Figure 52: Windows file sharing
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.
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:
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.
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.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.
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
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
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:
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:
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.
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|
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 θ
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 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
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
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
For 2 × 2 matrix
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 ,
178
Transposition
The transpose of a matrix, denoted with superscript T , is formed by interchanging row and
column elements:
For example,
A square matrix that multiplies another square matrix to produce the identity matrix is called
the inverse, and is denoted by a superscript − 1
Example 1
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.
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.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
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.
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.
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
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}
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
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
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
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 }.
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)
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.
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
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.
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
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}.
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.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
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
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,
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:
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)
Derivatives (Differential Calculus): The Derivative is the "rate of change" or slope of a function.
203
Simplify it as best we can, then make Δx shrink towards zero. Like this:
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
205
First and second order differential equations
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)
Notation
207
Graph 4: Indefinite integral
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
210
4.3.6 Learning outcome 5: Understand Probability and Statistics
4.3.6.1 Learning Activities
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
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
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 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
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.
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
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)
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.
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
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:
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
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.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.
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
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++.
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.
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.
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.
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.
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
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
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.
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
Let's look into the steps to set the PATH and CLASSPATH
Step 1) Right Click on the My Computer and Select the properties
229
Step 3) Click on Environment Variables
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
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.
232
• Select and click on the package you want to install.
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: 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.
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;
}
}
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 {
// ...
}
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
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
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.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
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.
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.
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
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;
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.
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
}
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;
}
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
246
String Constants
● String is a Sequence of Characters Enclosed between double Quotes These Characters may
be digits , Alphabets Like “Hello” , “1234” etc.
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.
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[])
{
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…..)
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.
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
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
252
5.3.5 Learning outcome 4: Use Control Statements
5.3.5.1 Learning Activities
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.
The statements which breaks the normal sequential flow of the program are called control
statements.
Branching statements
Branching statements are used to jump from the current executing loop.
● break
● continue
}
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.
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.
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
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
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 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.
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);
}
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.
Program Example:
public class ExampleVoid {
public static void main(String[] args) {
methodRankPoints(255.7);
}
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.
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.
// 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
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
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
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
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.
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.
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.
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.
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);
}
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!");
}
}
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.
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.
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
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
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.
✓ 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.
✓ 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.
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.
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.
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.
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.
.
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
"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
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)
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