0% found this document useful (0 votes)
6 views72 pages

Functions of Operating Systems Explained

The document outlines the essential functions and tasks of an Operating System (OS), including providing user interfaces, managing memory, security, processes, hardware, and files. It also discusses utility software that supports OS maintenance, such as virus checkers and disk management tools, and highlights the importance of program libraries for software development. Key examples of OS and utility software are provided, along with their advantages and disadvantages.

Uploaded by

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

Functions of Operating Systems Explained

The document outlines the essential functions and tasks of an Operating System (OS), including providing user interfaces, managing memory, security, processes, hardware, and files. It also discusses utility software that supports OS maintenance, such as virus checkers and disk management tools, and highlights the importance of program libraries for software development. Key examples of OS and utility software are provided, along with their advantages and disadvantages.

Uploaded by

maan khan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

x

5 System Software

5.1 | Operating System


5.1.1 The need for an Operating System (OS):
Operating System (OS):
It provides an interface between the user and the hardware.
Why a Personal Computer (PC) needs an Operating System:
The hardware is unusable without an OS as it hides the complexity of hardware from user.
It acts as an interface/controls communications between user and hardware/hardware and
software.
It provides software platform/environment on which other programs can be run.
Common examples of OS:
1. Microsoft Windows
2. Apple Mac OS
3. Google Android
4. Apples iOS
Basic functions of an Operating System (key management tasks):
1. Providing an interface
2. Memory management
3. Security management
4. Process management
5. Hardware management (input/output/peripherals)
6. File management

1
5.1.2 Functions/Tasks of Operating System:
1) Providing an Interface (provision of a user interface):
The operating system provides the Human Computer Interface (HCI) which allows the user
to communicate with the hardware.
It allows user interaction with the hardware/computer system by making navigation around
the system easier.
It provides a facility for user inputting data as well as outputting data to the user.
It hides the complexity of the hardware from the user.
For example: command line interface / GUI / menu-driven
The Human Computer Interface (HCI) is in the form of:
1. Command Line Interface (CLI)
2. Graphical User Interface (GUI)

1) Command Line Interface (CLI):


CLI (command line interface) is the one where user types a series of commands using
keyboard and communicates directly with computer system.
To use this, the user needs to know what commands are available, understand the commands
and understand the way information is stored in a computer system.
It is used by a programmer, analyst, or a technician (those who want direct communication
with computer).

How a user can select and open an application using CLI including any input hardware needed:
The user communicates directly with the computer system by typing in commands in
response to a prompt.
Several commands are entered to carry out a task such as simply loading software.
The input hardware needed for typing these commands is keyboard or keypad.

Advantages of CLI:
1. It allows direct communication with the computer system.
2. It is not restricted to a number of pre-determined options.
3. It is a simple interface using keyboard only.
4. It uses a small amount of computer memory

Disadvantages of CLI:
1. A user needs to learn a number of long and complex commands.
2. A user needs to learn how information is stored on a computer.
3. The user needs to type in commands which results in possibility of errors.
4. It is slower to type in commands every time.

2
2) Graphical User Interface (GUI):
Graphical interfaces are called GUI (graphical user interface) or WIMP (windows, icons, menus
and pointer) because it displays graphics as well as text.
GUI is very user friendly as the user can select options by use of menus of choices and small
pictures/icons which represent different available options.
Choices (icons) are selected by the user using a pointing device e.g., mouse and the selected
application is opened/run.
It is used by end-user who don’t have or need to have any great knowledge of how computer
works (a person who uses computer to run software, play games etc.).

How a user can select and open an application using GUI including any input hardware
needed:
The user interacts with a computer using pictures and symbols or a drop-down menu.
The tasks are initiated by selecting the icons (e.g., selecting the icon of a software to open it).
It is usually part of a windows environment.
The input hardware needed for selections is a pointing device (e.g., mouse) or a touch screen.

Advantages of GUI:
1. The user only needs to click on one simple picture rather than learning commands.
2. It is more user-friendly.
3. It is much easier for the beginners as only a pointing device is used to click on an icon to
launch the application.
4. Several instructions are replaced by just one icon.
5. There is no need to understand how a computer works.

Disadvantages of GUI:
1. It uses a considerable amount of computer memory.
2. The user is limited to the icons provided on the screen.
3. If the user wants direct communication, it is effectively more complex.

3
2) Memory Management:
It controls the movement of data between RAM, processor, VM etc.
It keeps track of allocated and free memory locations.
It ensures fair usage of memory.
It carries out memory protection to ensure that two programs do not try to use the same
space.
It organizes memory e.g., paging/segmentation.
It makes use of virtual memory.
It allocates memory to processes and decides which processes need to be in main memory
at any one time and releases memory when a process stops.
For example: when the process terminates, memory is made available.

3) Security Management:
It makes provision for recovery when data is lost.
It ensures privacy of data.
It sets up user accounts (provides usernames and passwords).
It prevents unauthorized access.
It implements access rights for all users.
It provides & upgrades firewall/anti-virus software.
It offers the ability for system restore (to previous stable state).

4) Process Management:
It manages the scheduling of processes/tasks and decides which process to run next that
allows multi-tasking/multi-processing and ensures fair access and handles priorities.
The scheduling of processes can be done by round-robin, shortest remaining time first etc.
It manages which resource the processes require.
It enables processes to share information.
It prevents interference between processes (resolution of conflicts) when two or more
processes require the same resource.

4
5) Hardware Management (input/output/peripherals management):
It involves all input and output peripheral devices therefore it is also sometimes referred to as:
1. Peripheral management
2. Hardware management
3. Device management
4. Input/Output management
All of these management tasks are the same:
It manages communication between devices/hardware and software using device drivers.
It controls access to data being sent to/from hardware/peripherals.
It receives data from input devices and sends data to output device.
It installs appropriate driver softwares.
It keeps track of device status (free or busy) and ensures that every hardware resource has a
priority.
It manages interrupts/signals from the device.
It manages/controls queues and buffers (buffer management)
Printer management is an example of queue & buffer management. The following are printer
management tasks that the Operating System performs:
It installs printer driver.
It sends data to the printer buffer ready for printing.
If a printer is busy, then it sends data to the print queue.
It sends various control commands to the printer.
It receives and handles error messages and interrupts from the printer.

6) File Management:
It provides file naming conventions which can be used.
It maintains/creates file directory structures and specifies the logical method of file storage
(e.g. FAT or NTFS).
It divides storage space into file allocation units and the space is allocated to particular files.
It specifies tasks that can be performed on a file/folders (e.g. open, close, delete, copy, create,
rename, move etc.)
It ensures access control/implements access rights (implements password protection &
makes file sharing possible)

5
Exam Style Questions:
Question 1:

Answer:

6
Question 2:

7
Answer:

8
Question 3:

9
Answer:

10
Question 4:

11
Answer:

Question 5:

12
Answer:

13
Question 6:

Answer:

14
5.1.3 Utility Software (utilities):
They are a part of the operating system of a computer.
These are additional programs that help to maintain or configure the system.
They are routines which carry out important tasks which are necessary.

Examples of Utility Software are:

1. Virus Checker (Anti-Virus Software)


2. Defragmentation Software
3. Disk Contents Analysis/Repair Software
4. Disk Cleanup/System Cleanup Software
5. Disk Formatter Software
6. Disk Mirroring Software
7. File Compression Software
8. Back-up Software
9. Security Software

1) Virus Checker (Anti-Virus Software):


It scans files stored on a computer system for malicious code.
It scans files when they enter the system e.g., memory stick inserted, or file downloaded etc.
It sets up a schedule for virus-checking.
It isolates/quarantines/deletes viruses.
It makes more RAM available for programs to run because it removes software that might be
taking up memory/replicating.
When does the virus checker perform a check?
It checks for boot sector viruses when the machine is first turned on.
It checks for viruses when an external storage device is connected e.g., memory stick.
It checks for viruses when a file/web page is accessed/downloaded.
2) Defragmentation Software:
It finds files that are split across the disk.
It moves individual files together, so they occupy contiguous blocks (blocks which are next to
each other/closer to each other).
This creates a larger area of (contiguous) free space.
It re-organizes the disk contents.
It improves disk access times as data/files can be loaded faster because each file is contiguous
(closer) to each other so there is less head movement.

15
3) Disk Contents Analysis/Repair Software:
It checks for any errors/bad sectors on the disk as some areas of disk can become corrupt.
It resolves any errors on the disk.
It marks bad sectors on the disk as unusable, which reduces access time by optimizing
storage.
It recovers damaged files/data from a damaged disk (recovers disc when data gets corrupt).
4) Disk Cleanup/System Cleanup Software:
It releases storage by removing unwanted/temporary files.
This improves system performance as memory is saved from unwanted data.
5) Disk Formatter Software:
It creates logical drives (partitions) on a hard drive.
It reformats a previously used hard drive.
It prepares a disk for first use.
It sets up the specified file system.
It may check for errors on the disk.
6) Disk Mirroring Software:
The data is stored on two disks simultaneously.
If the first disk drive fails, the data is accessed from the second disk.
7) File Compression Software:
It reduces the file size by using algorithms to change the data which can be either lossy or
lossless compression.
8) Back-up Software:
It makes a copy of data at regular intervals (e.g., daily, weekly, monthly etc.).
The copy of data is stored in a different location/elsewhere.
If the original data is lost/corrupted, then it can be restored from the backup.
It allows the user to decide what is backed up (e.g., all data // all files that have changed
since the last backup).
It may encrypt the backup files.
It creates a restore point where your computer can be restored to its state at this earlier
point in time.
9) Security Software:
It manages access control and user accounts (using user IDs and passwords).
It links into other utility software, such as virus checkers and spyware checkers.
It protects network interfaces e.g., through the use of firewalls.
It uses encryption and decryption to ensure any intercepted data is meaningless without a
decryption key.
It checks the updating of software e.g., update request comes from a legitimate source.

16
How the disk formatter, disk contents analysis and disk repair utilities work together.
The disk contents analysis checks for errors/problems with the disk.
The disk repair attempts to fix the errors.
The disk formatter prepares the disk for initial use again.

The following table shows whether the given programs are utility software or not:

Utility Not utility


Program
(✓) (✓)

Disk Defragmenter ✓

Word Processor ✓

Library Program ✓

Compression Software ✓

Database ✓

Virus Checker ✓

Web Browser ✓

Backup Software ✓

Language Translator ✓

Integrated Development Environment (IDE) ✓

Graphics Software ✓

Spreadsheet ✓

17
A few examples are given below which will help you better understand the utility software solutions
required for certain scenarios/statements according to the examination question.

Example 1:

Statement Utility software solution

The hard disk stores a large number of video files. The computer File compression
frequently runs out of storage space. software

The user is unable to find an important document. He thinks it was


Backup software
deleted in error some weeks ago. This must not happen again.

The operating system reports ‘Bad sector’ errors. Disk repair software

There have been some unexplained images and advertisements


Anti-virus software
appearing on the screen. The user suspects it is malware.

Example 2:

Statement Utility software solution

The user wants to send a large file as an attachment to an email. The


File compression
user knows that the recipient’s Internet Service Provider (ISP) has a
software
limit of 2MB for file attachments.

The user is writing a book and is worried that the document files
Backup software
could get damaged or deleted.

The computer has recently been slow to load large files. The user
has deleted a large number of small files to try to solve the problem. Disk defragmenting
A friend has advised that there is a procedure which should be software
regularly carried out to reorganize file storage on the hard disk.

The user clicked on an attachment in an unsolicited email. Since


Anti-virus software
then, the computer has shown some unexplained behaviors.

18
Example 3:
Sam is a photographer. She has an image library of over 10 000 images. She stores the images
on a high capacity magnetic hard disk.
Why Sam would use the following utility software:
(i) Backup software:
It would make a copy of her files (which can be stored elsewhere).
The images on the hard disk can be lost or corrupted.
This allows for images to be restored.
(ii) Defragmenter software:
The frequent changes to the images mean the data for each file is split across the disk.
It finds those files and rearranges them into contiguous blocks.
This creates more contiguous free space.
It improves the time taken to access and load the files.
(iii) Disk repair software:
It checks for any errors/bad sectors on the disk as some areas of disk can become corrupt.
It marks the errors/bad sectors on the disk as unusable so they can be repaired.
Those bad sectors are no longer used, which reduces access time.

19
Exam Style Questions:
Question 1:

Answer:

20
Question 2:

21
Answer:

Question 3:

22
Answer:

Question 4:

Answer:

23
Question 5:

Answer:

24
Question 6:

25
Answer:

26
5.1.4 Program Libraries:
The software under development is often constructed using existing code from program libraries.
The program libraries store pre-written functions and routines.
The program library can be referenced/imported.
The functions/routines can be called in the program being written by a programmer.
The programmer can utilize pre-written functions and routines in their own programs, thus
saving considerable development time.
They are used to help a software developer who wishes to use dynamic link library (DLL) subroutines
in their own program, so these subroutines must be available at run time. When software routines
are written (such as a sort routine), they are frequently saved in a program library for future use by
other programmers.
There are two program libraries containing:
1. Library programs
2. Library routines which are static and dynamic
In static libraries, the software being developed is linked to executable code in the library at the
time of compilation so the library routines would be embedded directly into the new program code.
Library Program:
A program stored in a program library is known as a library program.
Library Routine:
It is a pre-existing/pre-compiled/pre-written modules/code that can be linked into a program
without amendment.
It can be used to perform common/complex tasks.
Benefits to programmer of using Library Routines/Library Files/Library Programs/Program
Libraries:
1. The code is already written so the programmer does not have to write from scratch which
saves programming time.
2. The code is pre-tested (will have been used by many people) so it saves testing time and it is
more robust/more likely to work.
3. The code can be written in a different programming language making use of special features
of that language.
4. The programmer can use complex algorithms (e.g. mathematical/graphics functions) which
they may not know how to code/write and can still be sure that the function will perform as
it should.
5. It simplifies the program and makes it easier to read since just the name of the library function
is included in the source code.
6. It makes use of another programmer’s knowledge.

27
7. If there is an improvement in the library routine the program updates automatically.
8. The library routine code should conform to industry standards and therefore contribute
towards a more robust program.
Drawbacks to programmer of using Library Routines/Library Files/Library Program/Program
Libraries:
1. There could be compatibility issues as it may not work with the other code/may require
changing program for it to work.
2. It is not guaranteed thorough testing and may contain unknown or unexpected bugs/virus.
3. The library routine may not meet exact needs and may give unexpected results.
4. If the library routine is changed there may be unexpected results/errors.
In dynamic libraries, the software being developed is not linked to the library routines until actual
run time and these are known as Dynamic Link Library files (DLL).
Dynamic Link Library (DLL):
It is a collection of self-contained (shared library) programs that are already compiled.
It is linked to the main program during execution.
The library program code is saved separately from the main .EXE files.
The library file is only loaded into main memory when required at run time.
The DLL file can be made available to several applications at the same time.
If the DLL routine is updated the program that uses it will run the update.
Benefits of using DLL files:
1. The executable file is smaller as DLL files are only loaded into memory when required.
2. The changes/improvements to the DLL file code are done independently of the main program
so there is no need to recompile the main program and all the programs using it will benefit.
3. A single DLL file can be made available to several application programs thus saving space in
memory.
Drawbacks of using DLL files:
1. The executable code is not self-contained and the DLL files are needed to be included at run
time.
2. The appropriate linking software must be available at run-time to link/import the DLL files.
3. The DLL file must be present otherwise unable to find [Link] errors will occur.
4. The unexpected changes to the DLL file could mean the program stops working as expected.
5. The malicious changes to the DLL file could install a virus on the user’s computer and related
files could be corrupted.

28
Annchi is writing a computer game with a group of friends. One of her friends has suggested
using Dynamic Link Library (DLL) files to help them develop the game.
Reasons why Annchi and her friends should use DLL files when developing the game:
1. The executable file for the game is smaller as DLL file is only loaded into memory when
required.
2. The changes/improvements to the DLL file are independent of the main program so there is
no need to recompile the game program and the game program will get the benefit of the
updates automatically.
3. The same DLL file can be used in several game programs at the same time.
4. The DLL routines are pre-written saving the developers time.
5. The DLL routines are pre-tested so they should be reliable.
6. The developers can take advantage of other programmers expertise.
Reasons why Annchi and her friends should not use DLL files when developing the game:
1. The game will not work if DLL is corrupted.
2. An external change to the DLL could stop the game working or change the way it works.
3. The DLL must be present at run time otherwise unable to find [Link] errors will occur.

29
Exam Style Questions:
Question 1:

30
Answer:

31
Question 2:

32
Answer:

33
Question 3:

Answer:

34
Question 4:

Answer:

35
5.2 | Language Translators
5.2.1 Programming Languages & Translators:
High-Level Language & Low-Level Language:
Computer Program:

It is a list of instructions that enable a computer to perform a specific task.


It can be written in:
1) high-level language
2) low-level language

High-Level Language:

Example of pieces of high-level language codes

Meaning of the term High-Level Language:


It is closer to human language/English.
It is machine independent, hence it is a portable language.
It is problem/logic focused.
It needs to be translated to low-level language (machine code) for processing by computer.

Examples: C++, Python, Java, Pascal etc.

36
Advantages of High-Level Language:
1. It is independent of the type of computer being used hence it is portable and works on
many different machines/operating systems.
2. It is easier/quicker to read/write/understand codes as uses English-like statements.
3. It is easier and quicker to debug.
4. It is easier to modify.
5. They have built-in functions/libraries which save time when writing the program.
6. It is easier to maintain programs in use.

Disadvantages of High-Level Language:


1. The programmer will not be able to directly manipulate the hardware.
2. The programmer may need to wait for translation before running.
3. The programs may be less efficient and larger.
4. The programs may not be able to make use of special hardware.

Why would a programmer choose to write code in a High-Level Language:


It is closer to human language/English, so it is easier/quicker to read/write/understand.
Therefore, it is less likely to make errors.
It is easier to debug and maintain the program.
It is portable as the program can be used on many different platforms because it is written in
source code and then it is compiled into object code.
They have built-in functions/libraries which save time when writing the program.
There is no need to manipulate memory addresses directly. Therefore, specialist knowledge
of manipulating memory locations/registers is not required.
The programmer only needs to learn a single language as this can be used on many different
computers.
It offers a greater range of programming languages.
It also offers the use of an Integrated Development Environment (IDE).

Low-Level Language:
Meaning of the term Low-Level Language:
It is machine code.
It may use mnemonics.
It is machine dependent.
The one line of code in low-level language represents a single instruction.
It has direct access to memory locations/registers.
It may need an assembler to be translated.

Examples: assembly code & machine code.

37
Advantages of Low-Level Language:
1. The programmer will be able to directly manipulate the hardware and make use of special
hardware.
2. It can make use of special machine-dependent instructions (machine specific functions).
3. It works directly on registers/CPU and memory locations.
4. It can be executed faster.
5. The translated program requires less memory.
6. The programmer has more control over what happens on the computer.

Disadvantages of Low-Level Language:


1. It is more difficult to read/write/understand codes.
2. It is error prone and difficult to debug codes.
3. It takes a longer time to write programs.
4. It is machine dependent and so not portable.
5. The programmer will have to manipulate memory locations.

Why would a programmer choose to write code in a Low-Level Language:


It allows direct access to a computer processor and allows the use of special hardware and
machine-dependent instructions.
The program code written in low-level language uses up less memory.
The program code written in low-level language allows faster execution of instructions.

Machine Code:

Example of pieces of machine code

It is the binary language/instructions that the computer uses and understands.


The machine code requires no translation to be understood by the computer.

38
Assembly Language:

Example of pieces of assembly language codes

It is a form of low-level programming language.


It uses mnemonic codes.
An assembler is needed to translate an assembly language program into machine code.
It is specific to the computer hardware.
It is not machine code at all and instead it needs to be converted into machine code for the
computer to understand.
It is often used to create drivers for hardware.

The following True & False statements are regarding Assembly Language:

True False
Statement
(✓) (✓)

Assembly language uses mnemonic code ✓

Assembly language programs do not need translator to be executed ✓

Assembly language is a low-level programming language ✓

Assembly language is specific to the computer hardware ✓

Assembly language is machine code ✓

Assembly language is often used to create drivers for hardware ✓

39
The following True & False statements are regarding High-Level Languages:

True False
Statement
(✓) (✓)

High-level languages need to be translated into machine code to



run on a computer

High-level languages are written using mnemonic codes ✓

High-level languages are specific to the computer’s hardware ✓

High-level languages are portable languages ✓

The following table compares High-Level Language, Assembly Language & Machine Code:

High-Level Assembly Machine


Statement Language Language Code
(✓) (✓) (✓)

It requires a translator to be processed by a computer ✓ ✓

It is an example of low-level language ✓ ✓

It uses mnemonics ✓

It uses English-like statements ✓

It is portable ✓

It can be used to directly manipulate hardware in the


✓ ✓
computer

40
Translators:
It is a utility program that converts a program written in high-level or low-level language into binary
instructions that can be understood/used by the computer.

Types of Translators:
Compiler:

It translates high-level language into low level language.


It translates the entire source code into machine code/object code all at once/in one go.
It produces an executable file in machine code that runs directly on the computer.
It is more difficult to modify the executable code since it is in machine code format.
It generates an error report at the end of translation of the whole program.
Once translated, the translator does not need to be present for the program to run.
It is more likely to crash the computer since the machine code produced runs directly on the
processor.
A compiled program is usually distributed for general use.

Working/Operation of Compiler:
It translates high-level language into machine code/low level language.
It translates the whole program (the source code) as a complete unit/all at once/all in one
go.
It creates an executable file/object code.
It provides an error report/list of errors for the whole code if errors are detected.
It optimizes the source code to run efficiently.

41
Interpreter:
It translates high-level language into low level language.
It executes a high-level language program one instruction/statement at a time.
It translates source code line by line.
It stops the execution as soon as the first error is encountered.
It continues translating when an error is fixed.
It allows slow speed of execution of program loops.
It is easier to debug since each line of code is analyzed and checked before being executed.
An interpreter is often used when developing a program.

Working/Operation of Interpreter:
It translates high-level language into machine code/low level language.
It translates a program (the source code) one line of code at a time/line by line/statement by
statement.
It stops execution when it encounters an error and will only continue translating when the
error is fixed.
It produces error messages to tell the user the exact location of the error.
The machine code is directly executed which means the interpreter is used each time the
program/code is executed.

Why a compiler or an interpreter is needed when running a high-level program on a computer:


The computer only understands machine code/binary language.
The compiler/interpreter converts the code into machine code/binary language.

42
Assembler:

It translates a program written in low-level language (assembly language) into machine code.
An executable file is produced in machine code.
It translates the entire source code into machine code/object code all at once/in one go.
It produces error messages and provides error diagnostics.
The assembled programs can be used without the assembler.
An assembled program is usually distributed for general use.

Summary of Translators:

Compiler Interpreter Assembler

Translates a high-level language Executes a high-level language Translates a low-level language


program into machine code. program a statement at a time. program into machine code.

An executable file of machine No executable file of machine An executable file of machine


code is produced. code is produced. code is produced.

One high-level language program


One high-level language One low-level language statement
statement may require several
statement can be translated into is usually translated into one
machine code instructions to be
several machine code instructions. machine code instruction.
executed.

Compiled programs are used Interpreted programs cannot be Assembled programs can be used
without the compiler. used without the interpreter. without the assembler.

A compiled program is usually An interpreter is often used when An assembled program is usually
distributed for general use. a program is being developed. distributed for general use.

43
Compiler & Interpreter:
An interpreter is mostly used when developing a program and a compiler is used to translate the
final program.
Why a programmer would make use of both an interpreter and a compiler when writing a
program in a high-level language:
Both are used to translate the high-level language into machine code for the computer to
understand.
The interpreter is used whilst writing the program during the development and to debug the
code line by line.
It makes debugging easier because errors are reported and corrected as they are found.
The compiler is used when the program/development is completed and to create a separate
executable file (.exe) so it no longer needed for the execution of program.
The program can be given to others without access to source code and the final program
does not need to be re-compiled each time it run.
If the program runs for the first time in a compiler, then it means there are no syntax errors.

Main Similarities between a Compiler & an Interpreter:


1. They both translate high-level language/source code into machine code/low-level language.
2. They both check for errors.
3. They both identify and report errors generating error diagnostics/messages.
Main Differences between a Compiler & an Interpreter:
1. An interpreter translates and executes the code line by line whereas a compiler translates and
executes the whole code all in one go.
2. An interpreter stops translating and reports an error as it finds one whereas a compiler
produces an error report/list of errors at the end of translation.
3. An interpreter does not produce an executable file, but a compiler does produce an
executable file.
4. An interpreter will execute the code until it finds an error whereas a compiler will not execute
any code if there are error present.
5. An interpreter allows correction of errors in real-time whereas compiler needs to retranslate
the code each time after errors are found and corrected.

44
5.2.2 Advantages & Disadvantages of Compiler & Interpreter:
An interpreter is mostly used when developing a program and a compiler is used to translate the
final program.
Advantages of Compiler:
1. The compiler produces an executable file which creates a smaller file size.
2. The user does not have access to source code so users are unable to make changes to the
program/modify it.
3. The compiled program will be machine independent/portable which means it can be used on
any hardware.
4. The compiled code executes faster than the equivalent for an interpreter.
5. The code does not have to be recompiled each time it is run.
6. Once translated, the compiler is not required to run the program.
7. All errors are reported in a single report meaning they can all be fixed at the same time.
8. The program can be distributed without the source code and so source code is kept secure
(cannot be stolen or plagiarized).
9. The cross-compilation is possible which means the program can be compiled to run on
different platforms.
Disadvantages of Compiler:
1. The program will not run if there are any errors.
2. The program must be recompiled after every change as errors cannot be corrected in real-
time.
3. The parts of the program cannot be tested, without all the program code being available.
4. One error may result in other false errors being reported.
Advantages of Interpreter:
1. It allows easier debugging as errors are immediately reported when detected and they can
be corrected in real time as they occur.
2. The errors are reported as the interpreter finds them.
3. An error can be corrected, and translation continued from where it stopped.
4. The effect of any change made to the code can be seen immediately.
5. It can run a partially complete program during development stage.
6. The parts of the program can be tested, without all the program code being available.
Disadvantages of Interpreter:
1. The source code is needed at run time.
2. No executable file is produced so source code can be edited and modified.
3. The translation software (interpreter) is needed every time the program is run.
4. The programs can take longer to execute than the equivalent for a compiler.

45
A few examples are given below which will help you better understand the choice of each translator
according to the required use (scenario) and the benefits being provided by that translator for
choosing that particular translator according to the examination question.

Example 1:
A program is written using a high-level language so it will be published and sold for profit.
The program is compiled when it is completed.
Benefits of compiling the program:
1. It produces an executable file which creates a smaller file size that is more saleable.
2. The program will be machine independent/portable which means it can be used on any
hardware.
3. There is no need for a compiler to run executable file which means it will be quicker to run
and the customers can just execute the program.
4. The source code cannot be accessed and therefore code cannot be stolen or plagiarized.

Example 2:
Which translator is the most suitable for the given tasks along with benefits of using that
translator for the task:
(i) To translate the code during development of the game:
Interpreter:
It is easier to debug as errors are immediately reported when detected.
Compiler:
All errors are reported in a single report meaning they can all be fixed at the same time.
There is no need to recompile code every time a test is run.
(ii) To translate the final program and upload to the website for distribution, without the
source code:
Compiler:
It creates an executable file, so a translator is no longer needed to run it.
The source code cannot be stolen as it can be provided without the source code.

46
A few examples are given below which will help you better understand the choice of each translator
according to the required use (scenario) and the explanation needed for choosing that particular
translator according to the examination question.

Example 1:
Dimitri is writing a computer program in a high-level language. He needs to send just the
machine code for the program to his friend, electronically. It is important that the program is
executed as quickly as possible.
Identify which translator will be most suitable for Dimitri to use. Explain your choice.
Compiler:
It does not require recompilation as compiled program can be executed without a compiler.
Therefore, it allows faster execution.
It provides an executable file hence allows him to just send machine code.
Dimitri's friend does not need translation/compilation software to execute the program.

Example 2:
Julius uploads his application to his website for people to download. Before he uploads the
application, he translates the code using a compiler.
Why Julius uses a compiler, rather than an interpreter, to do this:
It creates an executable file so he would not release source code.
The source code therefore cannot be stolen/edited.
The program would not need to be translated every time, so a translator is not required.
This makes it machine independent.

Example 3:
Three programmers are working on different projects:
• Alice is developing a program written in a low-level language
• Akbar is developing a program written in a high-level language
• Alex is preparing a program written in a high-level language for sale
State, with reasons, which type of translator each programmer should use. Each programmer
should be using a different type of translator:
Alice:
Assembler because it translates low-level language into machine code.
Akbar:
Interpreter because it is easier to identify where an error is and easier to debug a program.
Alex:
Compiler because once translated, a stand-alone program file is created and there is no need
for the compiler when running the program so it can be distributed for general use and sales.

47
Example 4:
Ishani uses an interpreter and compiler at different stages of game creation.
(i) When it is most appropriate for Ishani to use an interpreter:
It is most appropriate during development // when writing the program // when debugging.
The interpreter makes the code easier to debug.
It stops when an error is detected and reports one error at a time.
It can correct errors in run-time.
It can test one section without the rest of the code being completed.

(ii) When it is most appropriate for Ishani to use a compiler:


It is most appropriate after completion // for distribution // for final testing.

After completion, the compiler creates an executable file that can be distributed without source
code:

The source code cannot be edited/viewed by other people.


End users do not need translator software and so the game is machine/platform independent.

In final testing, the compiler creates an executable file and so code does not need to retranslate
for each test sequence therefore it can be tested repeatedly with different data faster.

Example 5:
Jennifer uses an Integrated Development Environment (IDE) to write her computer program.
The IDE allows Jennifer to use both an interpreter and a compiler while creating her program.
Ways in which Jennifer can use both a compiler and an interpreter while developing the
program:
She can use an interpreter while writing the program to test/debug the partially completed
program. It also allows errors to be corrected in real time and the processing to continue from
where the execution stopped.
She can use the compiler after the program is complete to create an executable file. It can
also be used to repeatedly test the same completed section without having to re-interpret
every time.

48
Example 6:
Frankie is a software developer. He is developing a program to manage customer records for
a client with an online retail business. He must ensure that data stored about each customer
are both secure and private.
When the program is complete, Frankie uses a compiler to prepare the program for the client.
Why Frankie uses a compiler instead of an interpreter:
He uses a compiler because it creates a separate executable file.
The executable file means the client cannot access the source code.
The source code therefore cannot be stolen/edited.
The executable file means the client does not need the IDE/compiler.
It will probably be faster to run the executable than to interpret the source code every time
the program is run.

Example 7:
Each member of a group is creating a different part of a game. Each person needs to test their
part of the game independently before they are combined.
Identify the most appropriate type of translator that should be used to test each part of the
game independently. Justify your choice:
Interpreter:

The interpreter translates and executes line by line.


The interpreter stops translation when an error is found.
The error can be corrected in real time and the program continues running from where it
stopped.
There is no need for an executable file at the development stage.

Example 8:
Hannah is writing a computer program using a high-level language. She uses both a compiler
and an interpreter.
(i) Ways in which Hannah will use an interpreter while writing the program:
It will be used to run/test the incomplete program.
It will locate individual errors in the program because the interpreter stops.
It will allow the programmer to correct errors in real-time.
The changes can be made to the program and the effects of those changes can be seen in
real-time.

(ii) Reasons why Hannah uses a compiler when she has finished writing the program:
It is used to run/test the program multiple times without re-compiling.
It is used to produce an executable file so that it can be distributed without the source code.

49
The following tables compare Interpreter & Compiler:

(i) Table 1:

Interpreter Compiler
Statement
(✓) (✓)

takes one statement at a time and executes it ✓

generates an error report at the end of translation of the whole



program

stops the translation process as soon as the first error is



encountered

slow speed of execution of program loops ✓

translates the entire program in one go ✓

(ii) Table 2:

Interpreter Compiler
Statement
(✓) (✓)

creates an executable file that runs directly on the computer ✓

more likely to crash the computer since the machine code



produced runs directly on the processor

easier to debug since each line of code is analyzed and checked



before being executed

slow speed of execution of program loops ✓

it is more difficult to modify the code since the executable code is



now in the machine code format

50
(iii) Table 3:

Interpreter Compiler
Statement
(✓) (✓)

Translates the source code into machine code all at once ✓

Produces an executable file in machine code ✓

Executes a high-level language program one instruction at a time ✓

Once translated, the translator does not need to be present for the

program to run

An executable file is produced ✓

(iv) Table 4:

Interpreter Compiler
Statement
(✓) (✓)

It is more difficult to debug the code since one error can produce

many other associated errors

The speed of execution of program loops is slower ✓

It produces fast, executable code that runs directly on the



processor

It is easier to debug the code since an error is displayed as soon as



it is found

51
The following tables compare Assembler, Compiler & Interpreter:

(i) Table 1:

Assembler Compiler Interpreter


Statement
(✓) (✓) (✓)

Translates high-level language into machine code ✓ ✓

Provides error diagnostics ✓ ✓ ✓

Translates whole program to object code in one


✓ ✓
operation

Translates and executes one line of code at a time ✓

(ii) Table 2:

Assembler Compiler Interpreter


Statement
(✓) (✓) (✓)

Translates low-level language to machine code ✓

Translates high-level language to machine code ✓ ✓

Produces error messages ✓ ✓ ✓

Translates high-level language one line at a time ✓

Produces an executable file ✓ ✓

52
Exam Style Questions:
Question 1:

Answer:

53
Question 2:

Answer:

54
Question 3:

Answer:

55
Question 4:

Answer:

56
Question 5:

Answer:

57
Question 6:

Answer:

Question 7:

58
Answer:

Question 8:

59
Answer:

Question 9:

60
Answer:

Question 10:

Answer:

61
Question 11:

Answer:

62
5.2.3 Partial Compiling & Partial Interpreting:
In order to achieve shorter execution times, many high-level languages programs use a
system that is partially compilation and partially interpretation.
The source code is checked and translated by a compiler into object code.
The compiled object code is a low-level machine independent code, called intermediate code,
p-code or bytecode.
To execute the program, the object code can be interpreted by an interpreter or compiled
using a compiler.
For example: Java and Python programs can be translated by a compiler into a set of instructions
for a virtual machine. These instructions, called bytecode, are then interpreted by an interpreter.
Advantage of using a language that is partially compiled and partially interpreted:
1. The programs may be interpreted on different platforms.
Disadvantage of using a language that is partially compiled and partially interpreted:
1. The intermediate code/program still needs to be interpreted on the user’s computer, which
may run slowly.
2. The extra CPU resources may be required.

Java Programming Language:


The Java programming language is machine or platform independent.
Machine Independent:
The program code can be translated to run on any processor/platform.
The source code is translated into machine independent intermediate code not machine
dependent code.
How a Java source code program is translated:
The Java uses a two-step translation process.
The Java code is partially interpreted and partially compiled.
The code is translated first into intermediate code/bytecode using the Java compiler.
The bytecode is finally interpreted by the Java Virtual Machine.

63
Exam Style Questions:
Question 1:

Answer:

Question 2:

64
Answer:

Question 3:

Answer:

65
5.2.4 Integrated Development Environment (IDE):
It is a software that provides useful functions for a programmer writing a computer program.
It helps the programmers in writing and development of programs.
Most high-level programming languages offer the use of an IDE for program development.
This contains source code editor with an interpreter and/or compiler together with debugging
tools, which can improve the speed of program development.

There are many different IDEs available in which some just support one programming language
while others can be used for several different programming languages. NetBeans®, PyCharm®,
Visual Studio® and SharpDevelop are all IDEs currently in use.

Example of an IDE
Functions/Features of IDEs:
1. Source code editors
2. Translators (compiler and/or interpreter)
3. A runtime environment with a debugger
4. Auto-documenter

66
Features in IDE used for coding:
1. context-sensitive prompts
Features in IDE used for initial error detection:
1. dynamic syntax checks
Features in IDE used for presentation:
1. prettyprint
2. expand and collapse code blocks
Features in IDE used for debugging:
1. single stepping
2. breakpoints i.e. variables, expressions, report window

Description of IDEs Features:


1) Source code editors:
A source code editor allows a program to be written and edited without the need to use a
separate text editor.
The use of an integrated source code editor speeds up the development process, as editing
can be done without changing to a different piece of software each time the program needs
correcting or adding to.
Most source code editors color code the words in the program and layout the program in a
meaningful way called prettyprinting.
Prettyprint:
This is color-coding of keywords, built-in function calls, comments, strings, and the
identifier in a function header.
It presents characters with line breaks and indentations to make code comprehensible.
It makes source code easier to read due to better presentation.
It also increases the ability to reuse strings.
Some source code editors also offer context-sensitive prompts that displays predictions of
the code being entered with text completion for variable names and reserved words, and
provide dynamic syntax checking.
The dynamic syntax checking finds possible syntax errors as the program code is being
typed in to the source code editor and alerts the programmer at the time, before the source
code is interpreted. It underlines or highlights statements that do not meet the rules of the
programming language.
Many errors can therefore be found and corrected during program writing and editing before
the program is run.
The logic errors can only be found when the program is run.

67
For larger programs that have more than one code block, some code blocks can be
expanded and collapsed to a single line in the editor allowing the programmer to just see
the code blocks that are currently being developed.
2) Translators:
Most IDEs usually provide a translator, this can be a compiler and/or an interpreter, to enable
the program to be executed.
An interpreter is mostly used when developing a program.
A compiler is used to translate the final program to be used.
3) A runtime environment with a debugger:
A debugger is a program that runs the program under development.
It allows the programmer to step through the program one line at a time called single
stepping or to set a breakpoint to stop the execution of the code at a set line/point in the
source code.
A report window then outputs the contents of the variables, data structures, and
expressions evaluated at that point in the program.
This allows the programmer to see if there are any logic errors in the program and check that
the program works as intended.
Each variable used is shown in the report window together with the type and the contents
of the variable at that point in the program.
4) Auto-documenter:
Most IDEs usually provide an auto-documenter to explain the function and purpose of
programming code.

68
How a programmer can make use of an Integrated Development Environment
(IDE) when writing and testing a program:
(i) Writing a program:
The programmer can enter code into an editor.
The programmer can use pretty printing to identify key terms.
The programmer can use context-sensitive prompts to help complete statements.
The programmer can expand and collapse code blocks.
The programmer can use auto-complete to suggest what to type next.
The programmer can use auto-formatting to indent code blocks.
The programmer can use dynamic syntax checking.
(ii) Testing a program:
The programmer can use single stepping to run the code line by line.
The programmer can set breakpoints to stop the code at set points to check values.
The programmer can use report window to see how variables change.

69
Exam Style Questions:
Question 1:

Answer:
• Software that provides useful functions for a programmer writing a computer program.

Question 2:

70
Answer:

Question 3:

71
Answer:

72

Common questions

Powered by AI

Translators like compilers and interpreters facilitate the execution of high-level language programs by converting them into machine code that computers can understand. Compilers translate entire programs at once, creating an executable file for efficient distribution and execution. Interpreters translate each line of code on-the-fly, enabling immediate error resolution during development and making debugging more straightforward. Both ensure that high-level programs can be understood and executed by computer systems .

Compilers translate entire high-level language programs into machine code at once, creating an executable file, which allows for faster execution post-compilation and makes the program source code unavailable to end users. Conversely, interpreters translate and execute the program line-by-line, facilitating immediate error detection and debugging. Programmers often use interpreters during development for debugging and testing small code blocks, while compilers are used for final deployment to protect source code and enhance performance .

Utility software maintains computer system efficiency by performing tasks such as virus scanning to protect against malicious code, disk defragmentation for optimal file arrangement, disk cleanup to remove unnecessary files and free up space, and system backups to secure data. For example, defragmentation software rearranges files for faster access, and disk repair software resolves disk errors to prevent data loss and optimize storage .

Security software tools maintain system integrity by managing access through user accounts and passwords, using firewalls to protect network interfaces, and employing encryption to ensure intercepted data remains unreadable. They integrate with virus checkers and spyware checkers, regularly update software from legitimate sources, and immediately address vulnerabilities to protect against breaches .

File compression software optimizes storage and data transmission by reducing file sizes through algorithm-based modifications. Lossy compression permanently removes data deemed unnecessary, significantly reducing file size but potentially affecting quality. Conversely, lossless compression reduces size without data loss, preserving original file integrity. Lossless is beneficial for data-sensitive files, while lossy suits non-critical media .

Backup software contributes to data protection by regularly creating copies of data that are stored separately from the primary location. This redundancy ensures that data can be restored in the event of loss, corruption, or disaster. The typical process involves selecting data to backup, scheduling regular intervals for creating backups, and possibly encrypting the backup to maintain security. This software can also create restore points for system recovery .

An operating system manages file access and ensures data security by providing file naming conventions, maintaining directory structures, specifying tasks such as open, delete, and move, and implementing access control measures like password protection. It divides storage into allocation units, assigns space to files, and enables file sharing while preventing unauthorized access and interference .

A programmer uses both a compiler and an interpreter to leverage their specific advantages. During development, an interpreter allows for rapid testing and debugging by executing code line-by-line and providing immediate error feedback, enhancing code accuracy and efficiency. Once development is complete, a compiler creates an executable file that runs independently of the source code, protecting intellectual property and ensuring faster execution for end users without additional translation burdens .

A disk defragmenter enhances computer performance by reorganizing fragmented files on the hard disk so that individual files occupy contiguous blocks. This reduces the movement required to access data, thereby improving disk access times. Its use is particularly beneficial in scenarios where large files are frequently updated, such as in databases or video editing where hard disk space is heavily utilized, resulting in fragmentation .

The operating system manages hardware and peripheral devices through several key functions. It uses device drivers for communication between hardware and software, controls access to data being sent to and from peripherals, installs appropriate driver software, and tracks device status (free or busy). It also manages interrupts/signals from the device and controls queues and buffers, such as sending data to the print queue when a printer is busy, and handling printer error messages and interrupts .

You might also like