UNIT 2 CPF (Computer Programming Fundamental)
UNIT 2 CPF (Computer Programming Fundamental)
U
omputer Hardware & Software
C
I/O Devices
ninput/outputdevice,oftenknownasanIOdevice,isanyhardwarethatallowsahuman
A
operatororothersystemstointerfacewithacomputer.Input/outputdevices,asthename
implies, are capable of delivering data (output) to and receiving data from a computer
(input).Aninput/output(I/O)deviceisapieceofhardwarethatcantake,output,orprocess
data.Itreceivesdataasinputandprovidesittoacomputer,aswellassendscomputerdatato
storage media as a storage output.
I nput Devices
Inputdevicesarethedevicesthatareusedtosendsignalstothecomputerforperforming
tasks.ThereceiverattheendistheCPU(CentralProcessingUnit),whichhasworktosend
signals to the output devices. Some of the classifications of Input devices are:
Keyboard Devices
●
●Pointing Devices
●Game Controller
●Visual Devices
●Audio Input Devices
Output Devices
utputDevicesarethedevicesthatshowustheresultaftergivingtheinputtoacomputer
O
system.Outputcanbeofmanydifferentformslikeimage,graphicaudio,video,etc.Some
of the output devices are below.
Monitor
●
●Television
●Printer
●Speakers
●Projector
●Plotter
●Braille Reader
●Video Card
●Headphones
Definition of Software
oftware is a collection of instructions, data, or computer programs that are used to run
S
machines and carry out particular activities. A device’s running programs, scripts, and
applications are collectively referred to as “software” in this context.In a computer system,
the software is basically a set of instructions or commands that tella computer what to do.
In other words, the software is a computer program that providesa set of instructions to
execute a user’s commands and tell the computer what to do. Forexample like MS-Word,
MS-Excel, PowerPoint, etc.
It is the opposite of hardware, which describes the physical aspects of a computer.
Types of Software
The chart below describes the types of software:
bove is the diagram of types of software. Now we will briefly describe each type and its
A
subtypes:
1.System Software
●Operating System
●Language Processor
●Device Driver
2.Application Software
●General Purpose Software
●Customize Software
●Utility Software
ystem Software
S
Systemsoftwareissoftwarethatdirectlyoperatesthecomputerhardwareandprovidesthe
basicfunctionalitytotheusersaswellastotheothersoftwaretooperatesmoothly.Orin
otherwords,systemsoftwarebasicallycontrolsacomputer’sinternalfunctioningandalso
controlshardwaredevicessuchasmonitors,printers,andstoragedevices,etc.Itislikean
i nterface between hardware and user applications, it helps them to communicate
witheachotherbecausehardwareunderstandsmachinelanguage(i.e.1or0)whereasuser
applications are work in human-readable languages like English, Hindi, German, etc. so
system software converts the human-readable language into machine language and vice
versa.
I t is designed to manage theresources I t is designed to fulfill t he
of the computer system, like memory requirements of the user for
and process management, etc. performing specific tasks.
the users.
ystem software plays a vital role for
S
the effective functioning of a system.
Operating System
Operating Systems basically manages all the resources of the computer. An operating
s ystemactsasaninterfacebetweenthesoftwareanddifferentpartsofthecomputerorthe
computerhardware.Theoperatingsystemisdesignedinsuchawaythatitcanmanagethe
overall resources and operations of the computer.
Operating System is a fully integrated set of specialized programs that handle all the
operations of thecomputer.Itcontrolsandmonitorstheexecutionofallotherprograms
that reside in the computer, which also includes application programs and other system
software of thecomputer.ExamplesofOperatingSystemsareWindows,Linux,MacOS,
etc.
n Operating System (OS) is a collection of software that manages computer hardware
A
resourcesandprovidescommonservicesforcomputerprograms.Theoperatingsystemis
the most important type of system software in a computer system.
rocess Management: The operating system is responsible for starting, stopping, and
P
managing processes and programs. It also controls the scheduling of processes and
allocates resources to them.
ecurity:Theoperatingsystemprovidesasecureenvironmentfortheuser,applications,
S
and data by implementing security policies andmechanismssuchasaccesscontrolsand
encryption.
Job Accounting:It keeps track of time and resourcesused by various jobs or users.
eviceManagement:Theoperatingsystemmanagesinput/outputdevicessuchasprinters,
D
keyboards, mice, and displays. It provides the necessary drivers andinterfacestoenable
communication between the devices and the computer.
Networking: Theoperatingsystemprovidesnetworkingcapabilitiessuchasestablishing
a ndmanagingnetworkconnections,handlingnetworkprotocols,andsharingresourcessuch
as printers and files over a network.
User Interface: The operating system provides a user interface that enables users to
interact with the computer system. This can be a Graphical User Interface (GUI), a
Command-Line Interface (CLI), or a combination of both.
irtualization:Theoperatingsystemprovidesvirtualizationcapabilitiesthatallowmultiple
V
operating systems or applications to run on a single physical machine. This can enable
efficient use of resources and flexibility in managing workloads.
ystemCalls:Theoperatingsystemprovidesasetofsystemcallsthatenableapplications
S
to interact with the operating system and access its resources. System calls provide a
standardized interfacebetweenapplicationsandtheoperatingsystem,enablingportability
and compatibility across different hardware and software platforms.
ore than one task or program or jobs are present inside the main memory at one pointof
M
time.
heOScouldpickandstarttheexecutionofoneofthejobsinmemory,wheneverthejobs
T
doesnotneedCPUthatmeansthejobisworkingwithI/OatthattimetheCPUisidleatthat
timetheOSswitchestoanotherjobinmemoryandCPUexecutesaportionofittillthejob
issues a request for I/O and so on.
Advantages
Disadvantages
ultitaskingoperatingsystemsallowmultipleuserstoperformmultipletasksatthesame
M
time. The allocationofsystemresourcessuchasinput/outputdevices,CPUandmemory
among processes can be easily managed by a multitasking operating system. There are
various states through which a processor passes to complete particular or multiple
executions. Multitasking is the ability of an OS to execute more than one task
simultaneously onaCPU machine as shown in the belowdiagram.
Advantages
●A Multitasking Operating System is capable of executingmultiple applications
simultaneously without slowing down the system.
●Each process is assigned a specific length of time(i.etime sharing), hence a
process does not have to wait for a longer duration to utilize CPU.
●A multitasking OS can effectively manage I/O devices,RAM, hard disks,CPUs,
and other computer resources.
●In Multi-Tasking Operating a user is capable ofexecuting multiple programs atthe
same time, such as games, browser, MS Word, and other services.●Memory
management is well-defined in multitasking operating systems.Because of this, the
operating system does not grant any permission forunwanted apps to waste RAM.
Disadvantages
●As a single processor is executing multiple processesat the same time thenthere
will be load on the CPU and the CPU may heat up.
●Computer system will be lagging if the processoris slow in the Multi-Tasking
Operating System while executing multiple programs simultaneously.●Main
memory(RAM) has to store multiple processes during multitasking sothere can be
memory boundation if the main memory is overloaded.
I n operating systems, to improve the performance of more than one CPU can be usedwithin
one computer system called Multiprocessor operating system.
Multiple CPUs are interconnected so that a job can be divided among them for faster
e xecution.Whenajobfinishes,resultsfromallCPUsarecollectedandcompiledtogive
thefinaloutput.Jobsneededtosharemainmemoryandtheymayalsoshareothersystem
resources among themselves. Multiple CPUs can also be used to run multiple jobs
simultaneously.
The basic organization of a typical multiprocessing system is shown in the given figure.
○ Increasedreliability:Duetothemultiprocessingsystem,processingtaskscanbe
distributedamongseveralprocessors.Thisincreasesreliabilityasifoneprocessor
fails; the task can be given to another processor for completion.
○Increased throughout:As several processors increase,more work can be done in
less
○The economy of Scale:As multiprocessors systemsshare peripherals, secondary
storage devices, and power supplies, they are relatively cheaper than
single-processor systems.
ime-sharing enables many people, located at various terminals, to use a particular
T
computer system at the same time. Multitasking or Time-Sharing Systems is a logical
extension of multiprogramming. Processor’s time is shared among multiple users
simultaneously and is termed as time-sharing.
hemaindifferencebetweenTime-SharingSystemsandMultiprogrammedBatchSystems
T
is that in case of Multiprogrammed batch systems, the objective is to maximize
processor use, whereas in Time-Sharing Systems, the objective is to minimizeresponse
time.
ultiple jobs are implemented by theCPUby switchingbetween them, but the switches
M
occur so frequently. So, the user can receive an immediate response.
noperatingsystemusesCPUschedulingandmultiprogrammingtoprovideeachuserwith
A
a small portion of a time. Computer systems which were designed primarily as batch
systems have been modified to time-sharing systems.
Advantages
Disadvantages
Advantages
Disadvantages
●Real-time operating systems have complicated layoutprinciples and are verycostly to
develop.
●Real-time operating systems are very complex andcan consume critical CPUcycles.
S ingle-User Operating System
noperatingsystemthatallowsasingleusertoperformonlyonetaskatatimeiscalleda
A
Single-User Single-Tasking Operating System. Functions like printing a document,
downloadingimages,etc.,canbeperformedonlyoneatatime.ExamplesincludeMS-DOS,
Palm OS, etc.
Advantages
Disadvantages
hemaingoalofdevelopingamulti-useroperatingsystemistouseitfortime-sharingand
T
batchprocessingonmainframesystems.Thismulti-useroperatingsystemisnowoftenused
inlargeorganizations,thegovernmentsector,educationalinstitutionslikelargeuniversities,
andonservers'sidesuchasUbuntuServerorWindowsServer.Theseserversallowseveral
users to access the operating system, kernel, and hardware at thesame time.
Advantages
I t is time saving as we don’t have to make changes in many desktops, instead can make
changes only to the server.
Disadvantages
If the connection to the server is broken, the user cannot perform any task on the client as
it is connected to that server.
ultitasking is of two types: Processor based and thread based. Processor based
M
multitaskingistotallymanagedbytheOS,howevermultitaskingthroughmultithreadingcan
be controlled by the programmer to some extent. The concept of multithreading
needs proper understanding of these two terms – a processandathread.Aprocessisa
programbeingexecuted.Aprocesscanbefurtherdividedintoindependentunitsknownas
threads. A thread is like a small light-weight process within a process. Orwecansaya
collection of threads is what is known as a process.
Advantages
Disadvantages
ultithreading is complex and many times difficult to handle. It has a few drawbacks.These
M
are:
● Ifyoudon’tmakeuseofthelockingmechanismsproperly,whileinvestigating
dataaccessissuesthereisachanceofproblemsarisinglikedatainconsistency
and dead-lock.
●If many threads try to access the same data, thenthere is a chance that the
situation of thread starvation may arise.
●Display issues may occur if threads lack coordinationwhen displaying data.
Virus
omputervirusesaimtodisruptsystems,causemajoroperationalissues,andresultindata
C
lossandleakage.Akeythingtoknowaboutcomputervirusesisthattheyaredesignedto
s pread across programs and systems. Computer viruses typically attachtoanexecutable
hostfile,whichresultsintheirviralcodesexecutingwhenafileisopened.Thecodethen
spreadsfromthedocumentorsoftwareitisattachedtovianetworks,drives,file-sharing
programs, or infected email attachments.
Antivirus Software
ntivirussoftwareisaprogramthatsearchesfor,detects,prevents,andremovessoftware
A
infections that can harm your computer. Antivirus can also detect and remove other
dangeroussoftwaresuchasworms,adware,andotherdangers.Thissoftwareisintendedto
beusedasapreventativemeasureagainstcyberdangers,keepingthemfromenteringyour
computerandcausingproblems.Antivirusisavailableforfreeaswell.Anti-virussoftware
thatisavailableforfreeonlyprovideslimitedvirusprotection,whereaspremiumanti-virus
software offers more effective security. For example Avast,Kaspersky, etc.