Operating Systems
Operating Systems
• Virus Checkers
• Virus checkers, offered by operating systems, provide the best defense against malware if kept up to date and
running continuously in the background, checking files before they are run.
• Antivirus software compares potential viruses to a database of known viruses, uses heuristic checking for
suspicious behavior, and quarantines potentially infected files for automatic or user-decided deletion.
• Regular updates and full system scans, such as weekly checks, are essential to detect new viruses or dormant
malware that may evade real-time scanning.
• Defragmentation software
• As an HDD fills up, file data becomes scattered across different sectors, tracks, and surfaces, leading to
fragmentation.
• Fragmentation increases data access time since the HDD's read-write head must move more frequently to retrieve
scattered file pieces. Contiguous storage of files would reduce this delay.
• Consider the following example using a disk with 12 sectors per surface.
• We have three files (1, 2 and 3) stored on track 8 of the disk surface.
• File 2 is deleted by the user and file 1 has data added to it. However, the file 2 sectors which become vacant are
not filled up straight away by new file 1 data since this would require ‘too much effort’ for the HDD resources.
• File 1 has been extended to write data in sectors 10 and 11. Now, suppose file 3 is extended with the equivalent
of 3.25 blocks of data.
• This requires filling up sector 9 and then moving to some empty sectors to write the remainder of the data – the
next free sectors are on track 11.
• If this continues, the files just become more and more scattered throughout the disk surfaces. It is possible for
sectors 4, 5 and 6 (on track 8) to eventually become used if the disk starts to fill up and it has to use up whatever
space is available.
• A disk defragmenter will rearrange the blocks of data to store files in contiguous sectors wherever possible;
however, if the disk drive is almost full, defragmentation may not work.
• Assuming we can carry out defragmentation, then track 8 now becomes:
• Defragmentation reduces the number of read-write head movements needed to access files, improving data
retrieval efficiency.
• Some defragmenters also perform cleanup by marking damaged data blocks as "unusable," preventing future data
from being written to those blocks.
• Disk content analysis/repair software
• Disk content analysis software is used to check disk drives for empty space and disk usage by reviewing files and
file folders.
• This can lead to optimal use of disk space by the removal of unwanted files and downloads (such as the deletion
of auto saving files, cookies, download files, and so on).
• Disk compression and file compression
• File compression is essential to save storage space and make it quicker to download/upload files and quicker to
send files via email.
• Disk compression utilities compress data before writing and decompress it during reading, prioritizing system
operations, and should not be uninstalled, as doing so would make previously saved data unreadable.
• Back-up software
• Operating system backup utilities allow scheduled backups, only backing up files that have changed, with best
practice suggesting three versions: the current file, a local backup, and a remote backup.
• Windows provides features like data restoration, restore points, and file version history through File History, which
creates hourly backups and keeps past file versions unless settings are changed.
• Mac OS Time Machine backs up hourly, keeps daily backups for the past month, and weekly backups for previous
months, automatically deleting older backups when the storage device is full.
• Program libraries
• Program libraries provide pre-written subroutines to help developers save time during software development by
reusing existing code, such as sort routines.
• Dynamic link libraries (DLL) contain subroutines that must be available at runtime, allowing developers to
integrate them into their own programs for efficiency.
• Suppose we are writing a game for children with animated graphics (of a friendly panda) using music routines and
some scoreboard graphics.
• Using pre-written routines from program libraries saves time and cost by avoiding the need to rewrite and retest
common code, promoting efficient and error-free development.
• This approach supports modular programming, enabling multiple developers to work simultaneously, maintain
consistency across related software, and uphold a company's "corporate image.“
• Operating systems utilize two types of program libraries: static libraries, where routines are linked and embedded
into the new program code at compile time, and dynamic libraries (DLL), where routines are linked only at
runtime.
• Dynamic link libraries allow multiple applications to access the same routines as standalone files, saving memory
by loading them into RAM only when needed.
• For instance, a new software program may include a link to a printer routine in a DLL, accessing and loading the
printer code only when the user requires it, rather than including the full routine in the main program.
• Translation and execution of programs
• Translators are systems software that convert programming instructions from languages other than machine code
into executable machine code, with three types of translators, each performing a specific role.
• Instructions in a program can only be executed when written in machine code and loaded into the main memory
of a computer.
• Assemblers
• Assembly language programs are translated into machine code by an assembler, which can either load the
program directly into memory or store it for later execution, requiring a loader program to execute it multiple
times without re-translation.
• Assembly language programs are machine-dependent and specific to a particular type of chip or computer, often
used for tasks requiring high-speed execution, such as operating systems, robotics, or control systems.
• Compilers and Interpreters
• High-level language programs can be translated into machine code by a compiler, which generates a stored object
program that can be executed multiple times without re-translation, or executed line-by-line using an interpreter
without generating a stored program.
• Compiled programs require a loader to load the translated code into memory, while interpreted programs execute
each line during runtime without storing a translated version.
• High-level languages are machine-independent and portable, able to run on various systems if a suitable compiler
or interpreter exists, with common examples including Java, Python, and Visual Basic.
• Compilers and interpreters are both used for high-level languages, with some IDEs offering both; interpreters are
helpful during early development, while compilers create stand-alone programs for repeated execution without
retranslation.
• Partial compiling and interpreting
• Some high-level languages use a combination of compilation and interpretation to optimize execution times,
where source code is compiled into intermediate code (p-code or bytecode), which is machine-independent.
• The intermediate code can then be either interpreted or further compiled for execution, as seen in languages like
Java and Python, where bytecode is executed by a virtual machine interpreter.
• Integrated development environment (IDE)
• An Integrated Development Environment (IDE) helps programmers write and develop programs, with some IDEs
supporting multiple programming languages; examples include NetBeans, PyCharm, Visual Studio, and
SharpDevelop.
• IDEs typically include a source code editor, a compiler or interpreter (or both), a runtime environment with a
debugger, and an auto-documenter.
• Source code editor
• A source code editor allows programmers to write and edit code within the same environment, speeding up
development by eliminating the need for a separate text editor.
• Most source code editors offer features like color coding, pretty-printing, context-sensitive prompts with text
completion, and dynamic syntax checking to enhance coding efficiency and readability.
• Here, string values are shown coloured green and integer values are shown coloured blue.
• Dynamic syntax checking identifies potential syntax errors as the code is being typed, allowing programmers to
correct mistakes before running the program, though logic errors are only detected during execution.
• In larger programs, code blocks can be collapsed into a single line in the editor, helping programmers focus on the
sections currently being developed.
• Compilers and interpreters
• Most IDEs include a compiler and/or interpreter, with the interpreter typically used during development and the
compiler for generating the final object code.
• In PyCharm, multiple interpreters can be configured for different versions of Python, and program results are
displayed through the provided runtime environment.
• A run-time environment with a debugger
• A debugger helps debug programs by allowing the programmer to step through code line-by-line (single stepping)
or set breakpoints to pause execution at specific points, displaying variable contents and evaluated expressions at
those moments to identify logic errors.
• The report window shows the type and value of each variable, with the most recently used one listed at the top,
and also displays results from calculations and other expressions for thorough debugging.
• Auto-documenter
• Most IDEs usually provide an auto-documenter to explain the function and purpose of programming code.