Sei sulla pagina 1di 85

Chapter 1

Abraham Silberschatz, Peter Baer Galvin, Greg Gagne,


Operating System Concepts, 9th Eds. Wiley – 2012.
The components of a computer system
Computer-System Organization
Interrupts

• By Stephen Charles Thompson (anon_lynx) -


Own work, CC BY-SA 3.0,
https://commons.wikimedia.org/w/index.php?
curid=23385273
Interrupts
• In general, hardware interrupts and their handlers are used to handle high-priority
conditions that require the interruption of the current code the processor is executing
[1][2].
• Interrupt handlers have a multitude of functions, which vary based on what triggered
the interrupt and the speed at which the interrupt handler completes its task. For
example, pressing a key on a computer keyboard,[1] or moving the mouse, triggers
interrupts that call interrupt handlers which read the key, or the mouse's position, and
copy the associated information into the computer's memory [2].
[1] "The Linux Kernel Module Programming Guide, Chapter 12. Interrupt Handlers". The
Linux Documentation Project. May 18, 2007. Retrieved February 20, 2015.
[2] Jump up to: a b c d Jonathan Corbet; Alessandro Rubini; Greg Kroah-Hartman
(January 27, 2005). "Linux Device Drivers, Chapter 10. Interrupt Handling" (PDF). O'Reilly
Media. Retrieved February 20, 2015.
https://en.wikipedia.org/wiki/Interrupt_handler
Interrupt timeline
Interactive Class:

Keywords Definition
Storage-device hierarchy
Timer
We must ensure that the operating system maintains control over
the CPU.

The operating system sets the counter. Every time the clock ticks,
the counter is decremented.

When the counter reaches 0, an interrupt occurs. For instance, a


10-bit counter with a 1-millisecond clock allows interrupts at
intervals from 1 millisecond to 1,024 milliseconds, in steps of 1
millisecond.
Interplay of all components of a computer system

DMA – Direct Memory Access


 Computers that have DMA channels
can transfer data to and from devices
with much less CPU overhead
than computers without DMA channels.

https://en.wikipedia.org/wiki/Direct_memory_access
Symmetric multiprocessing architecture

• Symmetric multiprocessing (SMP) involves a multiprocessor


computer hardware and software architecture where two or
more identical processors are connected to a single, shared
main memory, have full access to all input and output
devices, and are controlled by a single operating system
instance that treats all processors equally, reserving none for
special purposes.

• https://en.wikipedia.org/wiki/Symmetric_multiprocessing
Symmetric multiprocessing architecture

• By Ferry24.Milan - Own work, CC BY-SA 3.0,


https://commons.wikimedia.org/w/index.php?curid=17202548
Symmetric multiprocessing
architecture
The general structure
of a clustered system

A computer cluster is a set of


loosely or tightly connected
computers that work
together so that, in many respects,
they can be viewed as a single
system.

https://en.wikipedia.org/wiki/Com
puter_cluster
Computer Cluster

• By MEGWARE Computer GmbH - http://www.megware.com, CC BY-SA


3.0, https://commons.wikimedia.org/w/index.php?curid=925421
Interactive Class:

Keywords Definition
Transition from user to kernel mode
Process States

By No machine-readable author provided.


A3r0 assumed (based on copyright claims).
- No machine-readable source provided.
Own work assumed (based on copyright
claims)., Public Domain,
https://commons.wikimedia.org/w/index.
php?curid=639576
Process Management
The operating system is responsible for the following
activities in connection with process management:

• Scheduling processes and threads on the CPUs


• Creating and deleting both user and system processes
• Suspending and resuming processes
• Providing mechanisms for process synchronization
• Providing mechanisms for process communication
How Threads Work

• https://www.javamex.com/tutorials/threads/how_threads_work.shtml
Memory Management
The operating system is responsible for the following
activities in connection with memory management:

• Keeping track of which parts of memory are currently


being used and who is using them

• Deciding which processes (or parts of processes) and


data to move into and out of memory

• Allocating and deallocating memory space as needed


• https://www.youtube.com/watch?v=GsOUe2AauFo
Translation Lookaside Buffer
A translation lookaside buffer (TLB) is a memory cache that is used to reduce the
time taken to access a user memory location [1][2]. It is a part of the chip’s memory-
management unit (MMU). The TLB stores the recent translations of virtual memory
to physical memory and can be called an address-translation cache.

[1] "A Survey of Techniques for Architecting TLBs", Concurrency and Computation:
Practice and Experience, 2016.

[2] Arpaci-Dusseau, Remzi H.; Arpaci-Dusseau, Andrea C. (2014), Operating Systems:


Three Easy Pieces [Chapter: Faster Translations (TLBs)] (PDF), Arpaci-Dusseau Books

• https://en.wikipedia.org/wiki/Translation_lookaside_buffer
Pages (Virtual Memory &
Physical Memory)
Relationship between pages addressed by
virtual addresses and the pages in physical
memory, within a simple address space
scheme. Physical memory can contain pages
belonging to many processes. Pages can
be held on disk if seldomly used, or if physical
memory is full. In the diagram above, some
pages are not in physical memory.
https://en.wikipedia.org/wiki/Page_table
• By Traced by User:Stannered, original by
en:User:Dysprosia - en:Image:Virtual address space
and physical address space relationship.png, BSD,
https://commons.wikimedia.org/w/index.php?
curid=1895627
Translation Lookaside Buffer
• The TLB stores the recent translations of virtual memory to physical
memory and can be called an address-translation cache. A TLB may
reside between the CPU and the CPU cache, between CPU cache and
the main memory or between the different levels of the multi-level
cache. The majority of desktop, laptop, and server processors include
one or more TLBs in the memory-management hardware.

• https://en.wikipedia.org/wiki/Translation_lookaside_buffer
Steps In a Translation
Lookaside Buffer

• By Aravind krishna - Own work, CC BY-SA 4.0,


https://commons.wikimedia.org/w/index.php?curid=52083035
Translation Lookaside Buffer

• By Aravind krishna - Own work, CC BY-SA 4.0,


https://commons.wikimedia.org/w/index.php?curid=52083036
Translation Lookaside Buffer
• A common optimization for physically addressed caches is to perform the
TLB lookup in parallel with the cache access. Upon each virtual-memory
reference, the hardware checks the TLB to see whether the page number is
held therein. If yes, it is a TLB hit, and the translation is made. The frame
number is returned and is used to access the memory. If the page number is
not in the TLB, the page table must be checked. Depending on the CPU, this
can be done automatically using a hardware or using an interrupt to the
operating system. When the frame number is obtained, it can be used to
access the memory. In addition, we add the page number and frame
number to the TLB, so that they will be found quickly on the next reference.

https://en.wikipedia.org/wiki/Translation_lookaside_buffer
The von Neumann execution cycle at work
Central Processing Unit - CPU 2
3
0010 R1 PC
sum
0011 R2
0101 R3 I 5
1, 2, 3, 4
Control Unit

Main Memory

Arithmetic Logic Unit - ALU


0010 +
Input Output Subsystem 0011 =
0101
System Bus Based Neumann Model

CPU: Memory

Input and Output


ALU, Registers and Control Unit Subsystem

Data Bus

Address Bus

Control Bus

Adding a Bus based System: The modified von Neumann Architecture


File Management
The operating system is responsible for the following
activities in connection with file management:

• Creating and deleting files


• Creating and deleting directories to organize files
• Supporting primitives (modules, system calls) for
manipulating files and directories
• Mapping files onto secondary storage
• Backing up files on stable (non-volatile) storage media
File
Management

• https://www.slideshare.net/DamianGordon1/operating-systems-file-management
File Management

• https://www.slideshare.net/DamianGordon1/operating-systems-file-management
Cache Memory
Principle:

When we need a particular piece of information, we first check


whether it is in the cache.

If it is, we use the information directly from the cache.

If it is not, we use the information from the source, putting a


copy in the cache under the assumption that we will need it
again soon.
Storage Performance
Data Movement
Spooling

• Many jobs already waiting to be executed are awating on the


disk. One aspect of spooling is multiprogramming which
allows to keep the CPU constantly busy so to reduce
execution time.
Multiprogramming (spooling)
Hard
Disk

Input Reader CPU Printer

Spooling allows programs to "hand off" work to be done by the peripheral and then proceed to
other tasks, or do not begin until input has been transcribed. A dedicated program, the spooler,
maintains an orderly sequence of jobs for the peripheral and feeds it data at its own rate. 
https://en.wikipedia.org/wiki/Spooling
The I/O Subsystem
• In computing, input/output or I/O (or, informally, io or IO) is the
communication between an information processing system, such as a
computer, and the outside world, possibly a human or another
information processing system. Inputs are the signals or data received
by the system and outputs are the signals or data sent from it. The
term can also be used as part of an action; to "perform I/O" is to
perform an input or output operation.

https://en.wikipedia.org/wiki/Input/output
The I/O Subsystem
• I/O devices are the pieces of hardware used by a human (or other
system) to communicate with a computer. For instance, a keyboard or
computer mouse is an input device for a computer, while monitors
and printers are output devices. Devices for communication between
computers, such as modems and network cards, typically perform
both input and output operations.

https://en.wikipedia.org/wiki/Input/output#Interface
The I/O subsystem

• http://slideplayer.com/slide/6358677/
The I/O subsystem

The I/O subsystem consists of several components:

• A memory-management component that includes


buffering, caching, and spooling

• A general device-driver interface

• Drivers for specific hardware devices


Interactive Class:

Knowledge Recall
Protection
Protection, is any mechanism for controlling the
access of processes or users to the resources defined
by a computer system.

Mechanisms ensure that files, memory segments,


CPU, and other resources can be operated on by only
those processes that have gained proper
authorization from the operating system.
Protection
• System Integrity Protection comprises the following mechanisms:

• protection of contents and file-system permissions of system files and


directories;
• protection of processes against code injection, runtime attachment
(like debugging) and DTrace;
• protection against unsigned kernel extensions ("kexts").

• https://en.wikipedia.org/wiki/System_Integrity_Protection
Access Matrix

A protection domain specifies the


resources that a process may access

https://www2.cs.uic.edu/~jbell/
CourseNotes/OperatingSystems/
14_Protection.html
Access Matrix

When we switch a process from one domain to another,


we are executing an operation (switch) on an object (the domain).
Security
Security is to defend a system from external and
internal attacks.

Such attacks spread across a huge range and include


viruses and worms, denial-of-service attacks (which
use all of a system’s resources and so keep legitimate
users out of the system), identity theft, and theft of
service (unauthorized use of a system).
A boot-sector computer virus
Interactive Class:

Knowledge Recall
Linked Lists
• Linked lists are among the simplest and most common data structures. The
principal benefit of a linked list over a conventional array is that the list
elements can easily be inserted or removed without reallocation or
reorganization of the entire structure because the data items need not be
stored contiguously in memory or on disk, while an array has to be declared in
the source code, before compiling and running the program. Linked lists allow
insertion and removal of nodes at any point in the list, and can do so with a
constant number of operations if the link previous to the link being added or
removed is maintained during list traversal.

• On the other hand, simple linked lists by themselves do not allow random
access to the data, or any form of efficient indexing.

https://en.wikipedia.org/wiki/Linked_list
Linked Lists
• Linux uses a number of software engineering techniques to link together its data
structures. On a lot of occasions it uses linked or chained data structures. If each data
structure describes a single instance or occurrence of something, for example a
process (identified by a PID non negative integer, The default maximum value of
PIDs is 32,767 - http://www.linfo.org/pid.html) or a network device (which is
identified by the OS using a number - http://www.homesaustin.com/Documents/
DeviceDrivers.pdf), the kernel must be able to find all of the instances. In a linked list
a root pointer contains the address of the first data structure, or element, in the list,
then each subsequent data structure contains a pointer to the next element in the
list. The last element's next pointer would be 0 or NULL to show that it is the end of
the list. In a doubly linked list each element contains both a pointer to the next
element in the list but also a pointer to the previous element in the list. Using doubly
linked lists makes it easier to add or remove elements from the middle of list,
although you do need more memory accesses. This is a typical operating system
trade off: memory accesses versus CPU cycles.
http://www.linux-tutorial.info/modules.php?name=MContent&pageid=257
Kernel Data
Structures
The kernel maintains three important
tables/structures for managing open
files for process: the process table, the
file table, and the v-node/i-node info.

A virtual node (v-node) represents


access to an object within a virtual file
system.

The i-node is a data structure in a


Unix-style file system that describes a
file system object such as a file or a
directory.
All logical-log files have one of the
following status flags in the first
position: Added (A), Deleted (D), Free
(F), or Used (U).
https://www.ibm.com/support/knowledgecenter/en/SSGU8G_12.1.0/c
om.ibm.admin.doc/ids_admin_0691.htm
https://www.usna.edu/Users/cs/aviv/classes/ic221/s16/lec/21/lec.html
Doubly Linked
Lists

• http://slideplayer.com/slide/8806909/
Queues

• https://www.slideshare.net/imdadmanik/03-processes
Queues

• https://www.tutorialspoint.com/operating_system/os_process_scheduling.htm
Circular
Lists
• http://pages.cs.wisc.edu/~verno
n/cs367/notes/4.LINKED-
LIST.html

Advantages: 
1. If we are at a node, then we can go to any node. But in linear linked list it is not possible to
go to previous node. 2. It saves time when we have to go to the first node from the last node. It
can be done in single step because there is no need to traverse the in between nodes. But in
double linked list, we will have to go through in between nodes. 
http://www.xpode.com/ShowArticle.aspx?ArticleId=296
Stack and Heap
Stack is used for static memory allocation and Heap for
dynamic memory allocation, both stored in the
computer's RAM.

Variables allocated on the stack are stored directly to


the memory and access to this memory is very fast,
and it's allocation is dealt with when the program is
compiled. 

Variables allocated on the heap have their memory


allocated at run time and accessing this memory is a
bit slower, but the heap size is only limited by the size of
virtual memory .

http://net-informations.com/faq/net/stack-heap.htm

• https://gabrieletolomei.wordpress.com/miscellanea/operating-systems/in-memory-layout/
Kernel Data Structures:
Lists, Stacks, and Queues
Kernel Data Structures:
Lists, Stacks, and Queues
Kernel Data Structures:
Lists, Stacks, and Queues
A stack is a sequentially ordered data structure that uses the last in, first
out (LIFO) principle for adding and removing items, meaning that the last item
placed onto a stack is the first item removed. The operations for inserting and
removing items from a stack are known as push and pop, respectively.

An operating system often uses a stack when invoking function calls.


Parameters, local variables, and the return address are pushed onto the
stack when a function is called; returning from the function call pops those
items off the stack.
Kernel Data Structures:
Lists, Stacks, and Queues
A queue, is a sequentially ordered data structure that
uses the first in, first out (FIFO) principle: items are
removed from a queue in the order in which they
were inserted.
Kernel Data Structures:
Lists, Stacks, and Queues
Trees
Hash Functions
A hash function takes data as its input, performs a numeric
operation on this data, and returns a numeric value.

This numeric value can then be used as an index into a table


(typically an array) to quickly retrieve the data.

Whereas searching for a data item through a list of size n can


require up to O(n) comparisons in the worst case, using a hash
function for retrieving data from the table can be as good as O(1)
in the worst case.
Hash Functions

• By Jorge Stolfi - Own work, Public Domain,


https://commons.wikimedia.org/w/index.php?curid=6601264
Hash Maps
One use of a hash function is to
implement a hash map, which
associates (or maps) [key:value]
pairs using a hash function.

For example, we can map the key


operating to the value system.
Once the mapping is established,
we can apply the hash function to
the key to obtain the value from
the hash map.
Hash Maps
For example, suppose that a user name is mapped to
a password.

Password authentication then proceeds as follows: a


user enters his user name and password.

The hash function is applied to the user name, which


is then used to retrieve the password.

The retrieved password is then compared with the


password entered by the user for authentication.
Memory allocation with
Bitmaps and Linked Lists

http://www.idc-
online.com/technical_references/pdfs/information_technology/Memory_Management_with_
Bitmaps_and_Linked_List.pdf
Bitmaps
A bitmap is a string of n binary digits that can be used to represent the status of
n items. For example, suppose we have several resources, and the availability
of each resource is indicated by the value of a binary digit:

0 means that the resource is available, while 1 indicates that it is unavailable (or vice-versa).

The value of the ith position in the bitmap is associated with the ith resource. As an
example, consider the bitmap shown below:

001011101

Resources (for instance, disk blocks) 2, 4, 5, 6, and 8 are unavailable;


resources 0, 1, 3, and 7 are available
Interactive Class:

Knowledge Recall
Computing Environments
Two operating systems currently dominate mobile computing:
Apple iOS and Google Android. iOS was designed to run on
Apple iPhone and iPad mobile devices. Android powers
smartphones and tablet computers available from many
manufacturers.

A network operating system is an operating system that provides


features such as file sharing across the network, along with a
communication scheme that allows different processes on
different computers to exchange messages.
Client–Server Computing
Peer-to-Peer Computing
Another structure for a distributed system is the peer-to-peer
(P2P) system model.

In this model, clients and servers are not distinguished from


one another.

Instead, all nodes within the system are considered peers, and
each may act as either a client or a server, depending on
whether it is requesting or providing a service.
Peer-to-Peer Computing
Skype is an example of peer-to-peer computing.

It allows clients to
make voice calls and video calls and to send text messages over the Internet
using a technology known as voice over IP (VoIP).

Skype uses a hybrid peer-to-peer approach.


It includes a centralized login server, but it also incorporates
decentralized peers and allows two peers to communicate.
Virtualization
A hypervisor or virtual machine monitor
(VMM) is computer software, firmware
or hardware that creates and runs virtual
machines. A computer on which a
hypervisor runs one or more virtual
machines is called a host machine, and
each virtual machine is called a guest
machine.

https://en.wikipedia.org/wiki/Hypervisor

• https://pubs.vmware.com/vsphere-50/index.jsp?topic=
%2Fcom.vmware.vsphere.introduction.doc_50%2FGUID-7EE617A2-4A10-424F-BAE2-56CA6692A93F.html
Virtualization

Virtualization is a technology that allows operating


systems to run as applications within other operating
systems.

To allow an entire operating system written for one


platform to run on another.
Virtualization
Virtual machine implementations involve several components.

At the base is the host, the underlying hardware system that runs the virtual machines.

The virtual machine manager (VMM) (also known as a hypervisor) creates and runs virtual
machines by providing an interface that is identical to the host.

Each guest process is provided with a virtual copy of the host (see Figure in the next slide).

Usually, the guest process is in fact an operating system.

A single physical machine can thus run multiple operating systems concurrently, each in its
own virtual machine.
Virtualization
Cloud
Computing

• Public Domain, https://commons.wikimedia.org/w/index.php?curid=18327835


Cloud Computing
Open-Source Operating Systems
Linux: In 1991, a student in Finland, Linus Torvalds,
released a rudimentary UNIX-like kernel using the
GNU compilers and tools and invited contributions
worldwide

BSD UNIX has a longer and more complicated history


than Linux. It started in 1978 as a derivative of AT&T’s
UNIX.

Solaris: is the commercial UNIX-based operating


system of Sun Microsystems.
How to place a program under
the GNU General Public License
The process involves adding two elements to each source file of your
program:

1. A copyright notice (such as “Copyright 1999 Terry Jones”),

and

2. A statement of copying permission, saying that the program is


distributed under the terms of the GNU General Public License
How to place a program under the GNU General Public License: Statement of copying permission

Author Richard Stallman: http://www.gnu.org/licenses/gplhowto.html


“This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.”
Interactive Class:

Knowledge Recall

Potrebbero piacerti anche