You are on page 1of 26

Computer Architecture and Operating

Systems
1.Basic Concepts of Computer Architecture
1.1. Historical Overview
 The word “computer” first appeared in a book by Richard Braithwaite called The Yong Mans
Gleanings, in which he referred to a computer as a human who is good at executing
mathematical operations.
 Any device that assists people in performing calculations could be considered a computer.
 Turing’s machine is a general model of a central processing unit (CPU) which enables the
computer to manage data manipulation.
 The role of the vacuum tubes in the ENIAC is that of an ON/OFF switch (1/0) that makes the
calculations possible.
1.2. Digital Logic and Binary Arithmetic
 As we know, computers do not have ten fingers; instead, they have a lamp, which can show
only two different symbols (states): ON and OFF (or 1 and 0). This requires the computer to
utilize only these two symbols for counting. This counting system is called the binary system,
or 2-based system.

 Bitwise operators: Each 1 or 0 in a binary number is called a bit. These bitwise operators
perform functions bit-by-bit on one or two binary numbers.
 The logic gates are the building blocks of all electronic devices, including computers. In
electronics, the six bitwise operators AND, NAND, OR, NOR, XOR, and NOT are called basic
logic gates.
 The NOT operator, is the only bitwise operator that operates on a single binary number. It turns
all ones into zeros and zeros into ones.


 OR operator generates the union of two bits and is mathematically represented by ∨.

 AND operators can also be applied to two binary numbers. This is mathematically represented
by ∧.

 Similar to OR and AND operators, XOR operators can also be applied to two binary numbers.
This operation is represented mathematically by the symbol ⊕. If either bit is 1, then the output
is 1. If both bits are 1 or 0, the result is 0.

 NOR: Just like the other operators, NOR operators can also be applied to two binary numbers.

This operation is represented by the following equation: If both bits are 0, then the
output is 1; otherwise, the output is 0. To make it simpler, NOR is completely the opposite of
OR.

 NAND operates on two binary numbers, A and B, and it is represented by the following
equation: If at least one of the bits is 0, then the output is 1; otherwise, the output is 0.

 A digital electronic device such as a microprocessor is a highly complex electronic circuit that
processes discrete-values variables (like voltage). A digital circuit can be conceptualized as a
black box composed of the following four elements
o One or more input terminals that digest discrete values.
o One or more output terminals that produce discrete values.
o A functional specification to describe the relationship between input and output terminals.
o A timing specification to describe the time delay between any change in the input
terminals and the corresponding response in the output terminals.
 There are two types of digital circuits: combinational and sequential. In the first, the outputs of
the circuit depend only on the current values of the inputs, meaning that the current input values
are combined to produce the output values. In the second, the outputs of the circuit depend on
the current and previous values of the inputs, which means that the output depends on the
sequence of the inputs. The previous state of the inputs can be memorized by distilling the
previous inputs into a smaller chunk of information.
 Convert 10110 from binary to decimal

 For binary computing questions, convert the two binaries into a decimal, then find the
decimal number, then convert the result decimal to a binary again :
For example 0111 + 0101  7 + 5 = 12 , and 12 is  1100
1.3. Semiconductor Technology
 The problem with vacuum tubes was their size and high-energy consumption, so, in modern
computers, they have been substituted with transistors.
 A transistor is an electrical switch that can be controlled and put in the ON (1) or OFF (0) state
by applying different voltages to the input terminals.
 A transistor is made of three terminals: gate (g), source (s), and drain (d). The current flows
from the source to the drain, and the voltage at the gate regulates the flow of the current
between the two.
 Silicon and germanium are the most commercially used semiconductors because they have four
valence electrons, Valence electrons: The electrons in the outermost shell, i.e., the energy level
of an atom, are called valence electrons.
 The process of adding impurities to the silicon crystal to make it an electrical conductor is
called doping.
 There are two types of doping: n-type and p-type.
o With n-type doping, an atom of silicon is replaced with an atom with five electrons in its
outermost layer, such as phosphorous or arsenic. In this case, the extra electron of the
impurities is free inside the crystal and carries an electric current.

o P-type doping (illustrated below) involves an atom of silicon, which is replaced with an
atom possessing three electrons in its outermost layer, such as boron (B), so the extra
electron of a silicon atom is available to carry the electric current. The lack of the electron
in the impurity (in this case, boron) is called a hole, which is equivalent to a positive
charge.
1.4. Hardware Design and Hardware Description Languages
 Also known as a microchip, a set of electronic circuits on a small flat piece of semiconductor is
called integrated circuit (IC).
 There are two types of integrated circuits, depending on their application:
o Field portable gate array (FPGA) chips: The FPGA chips can be programmed or
configured at the field by the user, who is normally a manufacturer of electronic devices,
such as sound system equipment. This type of chip is made of thousands of logic blocks
linked via programmable interconnections.
o Application-specific integrated circuit (ASIC) chips: ASIC chips are pre-programmed by
the circuit manufacturer and cannot be modified by the user. In this context, a
manufacturer, e.g., a cell phone manufacturer, represents the creator of the product. The
CPU of your cell phone is an example of an ASIC.
 HDL focuses on behavioral models. It should be noted that HDL is not a programming
language like C, C++, or Python, but a declarative language without any execution.
2.Computer Architechture
2.1. Computer Architecture Design Goals
 A computer system is composed of two groups:
o Hardware, or the physical elements, such as memory or the central processing unit (CPU).
o Software, i.e., the programs that control the hardware, operation, and functionality of the
computer.
 Computer system organization describes the physical aspects of the system, how it is
implemented, and its functional elements and their interconnections.
 Computer system architecture describes what the system can do.
Example : If we have two CPU’s, one is Intel and other one is AMD, they have different
organization, but the same architecture.
 The main goal of computer system architecture is balancing the performance, reliability,
efficiency, and cost of a computer system.
 Von Neumann aimed to design a simple fixed-structure computer that could perform any
complex computation without hardware modification, as long as it is provided with proper
program and instructions.
 In Von Neumann architecture, the computer is composed of four main components:
o A processor as the computing part of the computer.
o A memory to store both data and instructions.
o One or more input/output (I/O) devices for transferring the data to and from the outside.
o A bus system as the means (i.e., wires) to transfer data and instructions between the
processor components and the memory.
 One of the main advantages of the von Neumann architecture is that the data and instructions
share the same memory unit, e.g., random access memory (RAM). Therefore, the instruction
could be modified in the same way as the data.
 The processor consists of the Control Unit (CU), Arithmetic\Logic Unit (ALU) and registers.
 There are three types of buses:
o Data bus. A bidirectional bus that carries the data and instructions between CPU
components and between CPU, memory, and I/O devices.
o Control bus. Another bidirectional bus that transmits control signals (such as write-
memory, read-memory, or nothing) between CPU elements and between CPU, memory,
and I/O devices to coordinate the computer operations.
o Address bus. This is utilized to exchange the address of the data and instructions that
should be sent or fetched.
 In the von Neumann architecture, instructions are fetched one by one from the memory. The
processor decodes and executes one instruction at a time, and, upon completion, looks for the
next instruction to fetch.

 The von Neumann bottleneck: is when the data and instructions are stored on a shared memory
and can only be accessed through the data bus. Therefore, when the data are transmitted via the
data bus, the CPU cannot do anything.
 To overcome the von Neumann bottleneck, the Harvard Architecture is used, which was
designed by IBM, in this architecture the components are same as the Von Neumann, however
there are two separate memories, for the data and instructions that can be accessed
independently through two separate buses: the data bus and the instruction bus. By accessing
the data and instructions through two separate buses, they can be fetched simultaneously, which
makes the process faster and more efficient.
2.2. Instruction Set Architecture
 In the von Neumann architecture, data and instructions are treated the same, which means that
we can modify the data as we would the instructions.
 An instruction specifies what a processor should do.
 There are two types of instructions set architecture (computers):
o Reduced instruction set computer (RISC): This is a minimal set of simple instructions. An
example of this is the Advanced RISC Machines (ARM) processor.
o Complex instruction set computer (CISC): This is a set of many instructions that aim to
execute a task in as few lines of a program as possible. An example of this type of
instruction set is the Intel Pentium processor.
 A RISC architecture also needs fewer transistors, meaning that there is more space on the CPU
hardware for extra registers.
 MIPS Instruction Set: used in many embedded computers, such as internet routers, digital
cameras, printers, gaming consoles, and in Internet of Things (IoT) devices.
 The MIPS is based on four design principles
o Simplicity favors regularity: This principle implies that the hardware can handle easier
instructions with a consistent number of operands.
o Make the common case fast: smaller and simpler hardware can decode the instruction and
its operands.
o Smaller is faster:
o Good design demands good compromises
 A program written in the assembly language should be translated into the machine language.
Encoding the instructions into the machine language is a part of ISA. MIPS has three general
types of machine language instruction formats (or encodings):
o R-type: need three registers as operands. For these instructions, two registers are used as
sources and one as the destination.
o I-type: have two operand registers and one immediate operand register.
o J-type: The operation code and address operand.
2.3. Microarchitecture
 The specific ordering of components like registers, ALU, and memories to implement the
instruction set architecture is called microarchitecture.
 The parameter “seconds per cycle” is called the clock period TC. This parameter is the time
needed to synchronize the circuits in the processor.
 The clock frequency depends on the circuit technology. For instance, a gate does not propagate
instantly, but rather has a propagation delay, which depends on the number of inputs and
outputs. The clock period is set to be the worst-case total propagation time within gates that
generates a signal needed in the subsequent cycle. The worst-case total propagation time
happens on one or more signal paths within the chip. These paths are called critical paths.
 The challenge of the microarchitecture is to design a processor with minimized execution time
by considering other factors, such as technology and cost. However, some non-processor
factors also affect the performance of the whole system, such as the hard-disk, memory, or
network connection.
2.4. System Design


 The role of the “sign extend” in a MIPS processor is to build a signed binary from an unsigned
binary number.
 A microarchitecture can be divided into two separate parts: the data path and the control unit.
The data path part operates on words of data and contains structures, such as memories,
registers, ALUs, and multiplexers. The control unit fetches the current instruction from the data
path and instructs it on how to execute the instruction.
3.Computer Hardware
3.1. Personal Computers
 A personal computer (PC) is a digital computer that will be used by a single person at a time.
 A single component transistor in a semiconductor package that is not integrated into a chip with
millions of transistors is called a discrete transistor.
 Discrete transistors have a single component in a semiconductor package.
 Magnetic Core memory was built from rings of hard magnetic material, which formed the
transformer core. Then, three to four electrical wires went through each core to form a
transformer winding. Magnetic hysteresis enabled each core to remember or store information.
 A GUI is a collection of visual interactive elements which enables the user to start and stop
programs, select commands, and perform other routine tasks using a mouse.
3.2. Mainframes
 A mainframe is a high-performance computer system equipped with a very large memory that
is designed to perform billions of simple tasks in real-time.
 The most important characteristics of mainframes, also known as RAS:
o Reliability. A reliable system results in the correct output within the expected time.
o Availability. This is the ratio of the real operational time to the expected operational time,
generally expressed in percentage.
o Serviceability. This refers to the simplicity and speed used to resolve system issues, based
on the idea that better serviceability results in higher availability.
3.3. Servers
 A server is a piece of hardware and software that is used to serve other computers, known as
clients; together, they form the client-server system.
 A server can support multiple clients, and a client can connect to multiple servers
simultaneously.
 The connection between server and clients can be realized through the local area network
(LAN), or over a wide-area network (WAN), like the internet.
 Different types of servers:
o Application servers provide an environment in which the applications can run, so that the
client can use them without installing them.
o Computing servers provide computing resources (e.g., CPUs or memory) to the clients.
o Database servers host the data and provide them to the authorized clients. Usually, a
database management system (DBMS) like MySQL or MongoDB should be installed in
this type of server.
o File servers host files and folders, and allows access to them to the authorized clients. It is
normally used within an organization over a local area network (LAN).
o Web servers host the content of websites (including images and text) and respond to the
(HTTP) requests of the client. Examples of web servers are web browser like Google
Chrome or Firefox.
o Mail servers, such as Microsoft Outlook, send and receive emails from clients. To this
end, mail servers use standard email protocols, such as (SMTP) for sending messages, and
the (IMAP) or the messaging application programming interface (MAPI) for receiving
messages.
 Servers use a redundant array of inexpensive disks (RAID) data storage virtualization
technology, where a server distributes all data among the provided hard disks. In the case of a
drive failure, the server will re-build the inaccessible data of the failed drive on a new drive.
 The motherboard of a server should support multiple CPU configurations and networking
requirements, and have a vast memory (for example a few terabyte RAM).


3.4. Supercomputers
 The term “supercomputer” is used as a synonym for the highest possible available computing
power.
 The performance of a supercomputer is calculated in FLOPS (floating-point operations per
second).
3.5. Mobile Systems
 Mobile computer systems are designed for mobility; to this end, all required resources for the
computer system, such as battery or wireless network connection, are integrated.
 Another essential component is the exchange of information through a portable (i.e., wireless)
network.
 Characteristics that include the design challenges of mobile computer systems:
o Location awareness. The location of a mobile computer system changes constantly, and
these changes demand-specific requirements of the hardware and software design.
o Limited device capabilities. The portability of mobile devices affects the size of the
device, which, in turn, limits critical resources such as memory and CPU.
o Limited power supply. Because the device should be portable, it must use rechargeable
batteries with a limited power supply.
o Network connectivity quality of service. The quality of the network connectivity is also an
important criterion in the design of a mobile computer service, as it is the only way that
the device can communicate with other devices and servers.
3.6. Embedded Systems
 An embedded system is a set of hardware and software with extra mechanical or electrical parts
(like sensors) which is designed for a specific function.
 Like any other computer system, an embedded system should have a processor and software
(operating system) to control the hardware. The heart of any embedded system is the processor
that receives the input and produces the output. In most embedded systems, the processor is a
microcontroller. Although this is a small, task-oriented processor with limited processing
capabilities, it has enhanced input/output options and minimal energy consumption. Normally,
it is not possible to add extra features (such as memory) to these microcontrollers. However,
embedded systems need memory to store executable code and necessary data. The memory of
an embedded system can come as a random access memory (RAM), a read-only memory
(ROM), or both, depending on the defined functionality of the system.
 An embedded system should also have input and output devices. The inputs of the system can
be devices such as sensors, communication signals, control buttons, or the output from another
embedded system; the output devices can be monitors or communication signals.
 A device driver is an embedded software module including the functionality required to operate
each hardware device.

4.Assembly Languages
4.1. Role and Importance of Assembly Languages
 We can imagine the assembly language as a symbolic machine language, in which the
assembler acts as a “translator,” changing the code from the assembly language to the machine
language.
 An assembly language is utilized to write code in terms of processor capabilities, and is
dependent on the instruction set architecture (ISA) to do so.

4.2. Introduction to Programming in Assembly Languages


 The memory in MIPS is an array of 232bytes (1 byte = 8 bits), where each byte has a 32-bit
address, and the addresses of the MIPS memory has the range of 0x00000000 to 0xFFFFFFFF.
However, only the first 231 bytes are available for the user data, while the rest (0x80000000 to
0xFFFFFFFF) are reserved for the operating system and read-only memory (ROM), so the
programmer does not have access to those bytes.
 Here are some assembly commands :
o Ori  $A, $0,0x2 adds a number 2 to a to register A.
o Addu  $C, $A, $B adds register A and B and put result in register C.
o Andi  load value to register with result of bitwise .
o Xori  This operator is similar to the OR operator, except for the fact that, when both
operands are one, its result is zero.
o Lw  Loads a word of data (4 bytes) from the main memory into the register.
o Sw  Copies a word of data from a register into the main memory.
o Subu  Subtracts two numbers by triggering a trap in case of an overflow.

4.3. Compiling and Linking


4.4. Application of Assembly Languages


 Assembly languages are still used in different domains. One reason for this is that they are one
of the most reliable approaches to develop the boot code of a computer system.
 The boot is responsible for initializing and checking the hardware of a computer system before
starting the operating system.
 Assembly languages are also used to develop the kernel of the operating system.
 Some of the reasons for using inline assembly could be to optimize the performance for a
specific architecture and to access the processor’s specific instructions, forcing the compiler to
choose them.
 A novel kind of code that can be run in modern web browsers and offers new features and
improvement in performance is the web assembly language. This language maintains all the
values of assembly languages (or even C), such as reasonable memory requirements, but
executes them to a very high standard directly inside web browsers.
 Assembly languages can also be used in reverse engineering, a process that generates the source
code from the machine code.

5.Operating Systems Basics


5.1. Role and types of operating systems
 The operating system (OS) is a computer program that facilitates the interaction between a
computer’s hardware and its applications.
 The goal of an OS is to hide the real hardware characteristics from the user, a process called
abstraction.
 Operating systems are also known as a middleware that provides an abstraction for application
programs.
 Operating systems are considered a resource manager that provides the controlled and ordered
allocation of resources, such as processor time, memory, and input/output (I/O) devices, to the
applications that need them. For example, if two applications need the processor for
computation, the operating system decides which one gets it first.
5.2. Operating system Kernel


 The hardware layer consists of the processor, memory, and I/O devices.
 Above this layer is the software layer, which consists of two sub-layers:
o The kernel mode: which includes the operating system.
o The user mode: which includes the user interface program and other applications.
 When software runs in the kernel mode, it has access to all hardware and can run any
instruction. However, the applications that run in the user mode only have access to a limited
number of instructions.
 In a monolithic operating system, the whole operating system runs as a single program in the
kernel mode.
 In this case, the operating system is coded as a collection of procedures (functions) linked
together in a single large executable binary file. In a monolithic OS, any component of the OS
can use function calls to communicate with any other component.
 Some major problems associated with the monolithic design are the large size of the kernel and
the fact that the failure of one service results in the failure of the whole system.
 In the microkernel design, the operating system is divided into small, well-defined modules. In
this architecture, only the microkernel module runs in kernel mode, while the rest of the
programs run in user mode.
 In a situation in which each device driver runs as a separate user process (program), a failure in
one of the drivers will only crash that hardware component, and the rest of the system can
continue working.
 In the MINIX 3 operating system, a process management server creates, manages, and destroys
processes.

5.3. File Systems
 The part of the OS that is responsible for managing the files is the file system. Where the OS
manages how files are structures and named, how they are accessed, and how they are used,
protected, implemented and managed.
 Structurally, there are two types of directories: one-level and hierarchical.
 The structure of a hard disk can be broken down into a hard disk drive track, which is a circle
with a specific width, and a sector, which is a subdivision of the track. A collection of several
sectors is called a hard disk block.
 A hard disk is composed of the master boot record (MBR), the partition table, and the partition
blocks. The blocks forming the partition are:
o The operating system in each partition
o The superblock, that contains the key parameters of the file system, such as a magic
number for Identifying the file system type or the number of blocks in the partition
o Free space manager that has information about the free space of the partition
o An array of data structures (one per file), called i-nodes, that contain information about the
files
o The root-directory, which sits at the top of the file system hierarchy
o A block containing all files and directories
 One of the most important aspects of implementing a file system is storing and keeping track of
the data on the hard disk. Although many approaches are possible, the one discussed here is
linked-list allocation.
 If the operating system wants to access block n, it must start at the beginning and read all
previous n-1 blocks. To resolve this problem, we use a table, called the file allocation table
(FAT), that is stored in the random-access memory (RAM) and contains the pointer word of
each block.
5.4. Memory management
 Memory management is the dynamic allocation of main memory according to existing
processes, and the main memory is shared between the operating system and the processes.
 The memory manager should allocate the space in the main memory for the OS and the
processes, so that as many processes as possible have sufficient memory to run. This does not
include managing the registers, which is usually done by hardware.
 The relocation problem arises because both processes refer to the absolute physical memory
address; a possible solution is static relocation, which entails adding a constant to all process
addresses when they are loaded into the memory. Despite its practicality, this is not the best
solution as it slows down the loading process.
 To realize memory allocation and avoid the relocation problem, the memory manager uses a
physical memory abstraction called address space, which is a set of addresses that a process
uses to address the memory. Each process has its own address space independent of other
processes.
 Memory often does not have enough space to let all processes run simultaneously. Therefore,
different approaches are used to distribute the memory between processes that are ready to run.
The simplest approach is called swapping; this means loading process A completely into the
main memory, letting it run for a while, and then putting it back to the hard disk. The next
process is loaded, and the swapping continues. Another approach is virtual memory, in which a
program is allowed to run even when only a part of it is on the main memory.
 When the size of a process is constant, it is easy to reserve a specific amount of memory for that
process, but, when the size of a process changes over time (e.g., by adding text to a file), a
dynamic memory allocation should be considered.
 Virtual Memory management is a memory management strategy that lets a program run, even
when only a part of it is on the main memory.
5.5. Processes and Threads
 A process is a central concept in any OS. Put simply, a process is an instance of a running
program and one of the oldest and most important abstractions offered by operating systems.
 Processes support (quasi) parallelism, even if there is only one CPU in the system. In this case,
one CPU is turned into multiple virtual CPUs: For example, even if a computer has only one
CPU, a user can edit a text while listening to music at the same time.
 A program that is brought into the memory and becomes a process has four parts:
o The stack, which is used for storing temporary data about the process, such as function
parameters and local variables.
o The heap, which is used for dynamic memory allocation during running time.
o Data, which are used for storing static and global variables.
o The executable section (also called text), which is used to store the compiled program
code read-in from non-volatile storage after the program is launched.
 There is only one CPU that switches back and forth between the processes. This rapid back and
forth switching is called multitasking.

 If a process is created by an operating system, this does not mean that it will be executed
immediately in the CPU. Instead, it will be in one of the following states:
o Ready, which means that it is waiting for CPU allocation immediately after creation.
o Running, which means that the process instructions are currently being executed in the
CPU (only one process can be in this state at a time).
o Blocked, which means that a process is unable to run until a certain external event occurs
(in the system, this is called a pause).
 In a conventional operating system, each process has a memory address, i.e., a range of the
memory address it can use, and a single thread of control.
 In modern operating systems, it is possible to have several control threads running in pseudo-
parallel in the same memory address, as they are separate processes. These sub-processes are
called threads, or processes within a process.
 There are several reasons to use threads, which include the following:
o In some applications, there are activities (modules) that run at the same time and some of
them may block occasionally. By decomposing a process into sub-processes, or threads,
the whole process will not be halted by a blocked module and can continue working.
o Creating and stopping threads is easier because they are simpler (lighter) than the
processes.
o When threads are in parallel, they can improve performance (e.g., when one thread needs
the CPU, the other needs I/O devices).

 The component of the operating system that decides the order of running processes is the
scheduler, using a strategy called scheduling algorithm. So if several process will compete for
the CPU at the same time, this scheduler will decide which goes first.
 One of the most common scheduling algorithms: round-robin scheduling (RR). Round-robin is
one of the oldest, simplest, and most widely used strategies. In the RR algorithm, each process
is assigned a time period, called a quantum, in which the process is permitted to execute. By the
end of the quantum, if the process is not done and needs more time, the CPU is interrupted and
another process is assigned. The scheduler must maintain a list of the processes that are
permitted to run. As soon as the process has used up its quantum, it is moved to the end of the
list.

5.6. Security
 The security of a computer system (or of any information system in general) is comprised of
three main components:
o Confidentiality ensures that the secret data should stay secret.
o Integrity guarantees that an unauthorized user cannot modify the data without the data
owner’s permission.
o Availability prevents access to unauthorized users by making the information system
unavailable.
 The functions of the operating systems that should be included in the TCB (Trusted Computer
Base) are process creation, process switching, memory management, and part of file and I/O
management.
 An important component of a TCB is the reference monitor. All system calls that involve
security should be verified by this unit. The reference monitor decides if a service call, such as
an opening file command, can be executed or should be rejected.
 One of the basic concepts in the domain protection approach is the principle of least authority,
this principle gives the minimum possible number of objects and rights to a domain.
 The access control list (ACL) is an ordered list associated with each object which contains all
domains that are authorized to access the object. This list implements the domain protection
strategy

6.Popular Operating Systems


6.1. Basic Concepts of Windows
 The NT Windows OS kernel core is the NTOS kernel-mode layer. This layer provides the
traditional system call used by other parts of the operating system. When the Windows
operating system boots, the execution of the ntoskrnl.exe executable program will run this
layer. The NTOS kernel layer is divided into two sub-layers: the architecture-independent layer
and the kernel layer.
 Above the kernel mode is the system library layer that runs in the user mode. This layer
includes some support functions for low-level libraries. Below the NTOS executive layer is the
hardware abstraction layer (HAL), whose function is to abstract the low-level hardware details,
such as registers. HAL also facilitates the operating system installation on different devices,
which is done by hiding details of the hardware, such as the processor model, from the rest of
the operating system. The abstractions of the HAL are provided in machine-independent
services that the NTOS and the drivers can use.
 The role of the system library layer in the Windows NT architecture is that it includes some
support functions for low-level libraries.

6.2. Basic Concepts of Unix and Linux


 Linux is an open-source operating system developed around the kernel of the UNIX operating
system.

 At the bottom of this pyramid-like structure is the hardware layer, which includes the CPU,
memory, and hard disk. The operating system layer runs in the kernel mode at the top of the
hardware layer. The Linux operating system has a monolithic design and includes a process
scheduler, memory manager, and file system. The Linux OS also provides the system call
interface for the programs, where the system calls are used by the user-mode programs to create
and manage processes, files, and other resources.
 The next layer is the standard library layer. User-mode programs issue a trap instruction to
switch from the user to the kernel mode. For each relevant system call, there is a single
procedure written in assembly language. It is called with a code written in C language and
packed in standard libraries. Therefore, to run a read system call, a C program calls the read
library procedure. Each version of the Linux operating system (such as Ubuntu) has its own
standard programs, e.g., command line (or shell). These programs are located at the top of the
standard library in the standard utility library programs.
 At the top of the pyramid is the graphical user interface (GUI), which facilitates the interaction
between the user and the operating system. Although Linux has a GUI, many programmers
prefer to use the command line interface, or shell. One of the variations of the shell is the bash
(an acronym for “Bourne again shell”), which is the standard shell on most versions of Linux.
The shell interface contains several standard utility programs that can be divided into five
categories:
o File and directory manipulation commands, such as the following command cp a b, which
copies file a into the file b.
o Filters, such as the code sort file.txt, which sorts the data in the file.txt alphabetically as
output.
o Program development tools, such as editors and compilers like the gcc utility program,
which compiles C and C++ codes.
o Text processing commands, such as vim.
o System administration commands, such as chmod, which changes the file access rights.
o
 The structure of the Linux kernel is shown in the figure below. As you can see, interrupts and
dispatchers are at the bottom of the Linux kernel. Interrupts are the primary means of
interaction with the hardware, while the dispatching process starts when an interrupt happens.
The low-level code of the dispatcher stops a process, stores its state, and starts the relevant
driver.

 The rest of the Linux kernel components are divided into three main categories:
o The I/O component contains all modules required for interacting with I/O devices. The
virtual file system (VFS) is at the top of the component, which enables multiple file
systems to be implemented and coexist. It also provides an interface between the file
system and user mode programs.
o The memory management component is responsible for managing the memory.
o The process management component creates and terminates processes and threads.
 The system call interface is at the top of the Linux kernel. The system calls from the user mode
applications are redirected to this interface, triggering a trap that results in the execution mode
change into a kernel mode execution. The control is then passed to one of the kernel
components.
6.3. Basic Concepts of Apple Operating Systems
 The figure below illustrates the general architecture of the different layers of Apple’s OS X
architecture:


 The OS X kernel environment, also called XNU, has the following main components, which,
together, provide the fundamental functionality of the OS X:
o Mach. This is responsible for most of the core kernel functionalities, such as managing the
processor resources, handling scheduling, managing memory, inter-process
communication, kernel debugging, and console input and output.
o The BSD layer. This is based on the Berkeley software distribution (BSD) version of the
UNIX. This unit provides services such as permissions, an application programming
interface (API) to portable operating system interface (POSIX) functions, BSD style
system calls, file system management, and UNIX security model.
o An I/O kit. This provides the dynamic device management and loading of drivers, and
power management for desktop systems.

6.4. Basic Concepts of Mobile Operating Systems


 A mobile operating system is designed for mobile devices such as smartphones, smartwatches,
tablets, and smart speakers (but not laptops).


 Android is built on the standard Linux kernel with several extensions, which place it at the
lowest layer of the Android software stack. Wake Locks is an extension that is designed to
manage the system’s power; also called suspend blocker, this extension controls how the
system goes into sleep mode. Another extension is the out-of-memory-killer, which helps the
system to recover from situations of extremely low memory.
 Android runtime is located above the Linux kernel. When an application is loaded into a mobile
device, the Android runtime (ATR) uses the ahead-of-time (AOT) compilation process to
translate the bytecode application (written in Java bytecode) into the machine language. This
format is known as “executable and linkable format.” Another component of the Android
Runtime is Dalvik, which provides a Java language environment for running applications, as
well as system codes such as window manager.
 The Android Libraries layers also lie above the Linux kernel. This includes libraries such as
SQLite (for database management); Android Blink (which provides tools for browsing the
web); Surface Manager (which composes drawing surfaces onto the screen); FreeType (an
engine for rendering fonts); ES & SGL (the core of graphics libraries),;and SSL (security socket
layer).
 The next layer is the application framework, which is a set of services that provide the
environment needed to run and manage applications. This layer is comprised of the following
key services:
o The activity manager controls the application life cycle.
o The content provider manages the data exchange between applications.
o The notifications manager provides services for applications to show alerts and
notifications.
o the package manager helps applications to receive information about other installed
applications on the system.
o the telephony manager informs applications about the telephony services available on the
device.
o the location manager helps the applications to obtain information about the device’s
location.
 At the top of the Android software stack is the applications layer, which includes both native
Android applications and third-party applications installed by the user.

You might also like