Ch03-OS
Ch03-OS
1
A Computer Model
• An operating system has to deal with the fact
that a computer is made up of a CPU, random
access memory (RAM), input/output (I/O)
devices, and long-term storage.
0
1
2
3
I/O CPU 4
5
6 RAM Disk Drive
7
8
9
.
.
.
2
OS Concepts
• An operating system (OS) provides the
interface between the users of a computer
and that computer’s hardware.
– An operating system manages the ways
applications access the resources in a computer,
including its disk drives, CPU, main memory, input
devices, output devices, and network interfaces.
– An operating system manages multiple users.
– An operating system manages multiple programs.
3
Multitasking
• Give each running program a “slice” of the CPU’s time.
• The CPU is running so fast that to any user it appears that the
computer is running all the programs simultaneously.
4
The Kernel
• The kernel is the core component of
the operating system. It handles the
management of low-level hardware
resources, including memory, User Applications Userland
9
File Systems
• A filesystem is an abstraction of how the external,
nonvolatile memory of the computer is organized.
• Operating systems typically organize files
hierarchically into folders, also called directories.
• Each folder may contain files and/or subfolders.
• Thus, a volume, or drive, consists of a collection of
nested folders that form a tree.
• The topmost folder is the root of this tree and is also
called the root folder.
10
File System Example
11
File Permissions
• File permissions are checked by the operating system to
determine if a file is readable, writable, or executable by a user
or group of users.
• In Unix-like OS’s, a file permission matrix shows who is allowed
to do what to the file.
– Files have owner permissions, which show what the owner
can do, and group permissions, which show what some
group id can do, and world permissions, which give default
access rights.
12
Memory Management
• The RAM memory of a computer is its address space.
• It contains both the code for the running program, its
input data, and its working memory.
• For any running process, it is organized into different
segments, which keep the different parts of the
address space separate.
• As we will discuss, security concerns require that we
never mix up these different segments.
13
Memory Organization
• Text. This segment contains the actual (binary) machine code of
the program.
• Data. This segment contains static program variables that have
been initialized in the program code.
• BSS. This segment, which is named for an antiquated acronym for
block started by symbol, contains static variables that are
uninitialized.
• Heap. This segment, which is also known as the dynamic segment,
stores data generated during the execution of a process.
• Stack. This segment houses a stack data structure that grows
downwards and is used for keeping track of the call structure of
subroutines (e.g., methods in Java and functions in C) and their
arguments.
14
Memory Layout
15
Virtual Memory
• There is generally not enough
computer memory for the address
spaces of all running processes.
• Nevertheless, the OS gives each
running process the illusion that it has
access to its complete (contiguous)
address space.
• In reality, this view is virtual, in that the
OS supports this view, but it is not
really how the memory is organized.
• Instead, memory is divided into pages,
and the OS keeps track of which ones
are in memory and which ones are
stored out to disk.
16
ATM
Page Faults
1. Process requests virtual address not in memory,
causing a page fault.
“Page fault,
let me fix that.”
Process
Paging supervisor
old
Blocks in
RAM memory:
18