Intro_to_OS_v02
-
Upload
geetalangote31831 -
Category
Documents
-
view
217 -
download
0
Transcript of Intro_to_OS_v02
-
8/14/2019 Intro_to_OS_v02
1/30
Definition
operating system (OS) is the systemsoftware responsible for the directcontrol and management of hardwareand basic system operations.Additionally, it provides a foundation
upon which to run application software
-
8/14/2019 Intro_to_OS_v02
2/30
Few OSs
1973 Unix the first kernel written in a portableprogramming language
1975 VAX/VMS1981 MS-DOS.
1983 AmigaOS
1984 Macintosh1987 OS/2
1993 FreeBSD
-
8/14/2019 Intro_to_OS_v02
3/30
Unix variations
AIX
BSDi
Digital UNIX (or DUNIX)
FreeBSD
GNU Hurd
HP-UX
IRIX
LINUXMac OS X
Mac OS X Server
NetBSD
NeXT
NeXTSTEP
OpenBSD
OPENSTEP
Pyramid
Rhapsody
SCO Solaris
SunOS
ULTRIX
-
8/14/2019 Intro_to_OS_v02
4/30
Kernel driver
Kernel driver can be:
System driver implement a system feature
like file system or TCP/IP stack.
Hardware driver implement a specific
hardware interface to the OS kernel.
-
8/14/2019 Intro_to_OS_v02
5/30
Hardware drivers
Provide general interface for the OS to accessdifferent brands with similar functionality.
For example all NICs driver have the same interfacewhile each driver speak differently to its NIC
hardware.
Hardware driver are layered!
The NIC drivers call the PCI drivers and so on.
-
8/14/2019 Intro_to_OS_v02
6/30
File System
Used mainly on Hard disks.
Provide directory hierarchy
And files with names and attributes.
Can provide security.
Modern file system provide journal forpower fail recovery
Example: FAT, NTFS, ext2, ext3, raiserfs.
-
8/14/2019 Intro_to_OS_v02
7/30
TCP/IP stack
Network stack layer 3.
Most OS today comes with its own stack.
However it is not a most!
In Linux the TCP/IP stack is a kernel driver.
-
8/14/2019 Intro_to_OS_v02
8/30
Memory management
Allocating memory in the form pages.
Separate kernel pages from user space pages
Activate the MMU (next slide)
Handle mapping of virtual addressing to
physical memory.
Kernel uses physical memory addressing.
-
8/14/2019 Intro_to_OS_v02
9/30
Memory management unit
Hardware component that provides:
Memory Protection
Access per mode.
Access can be read/write, read only and noaccess.
There is one access for data and one forinstruction fetch (running code)
Also enable the use of swap!
-
8/14/2019 Intro_to_OS_v02
10/30
Memory management unit
Virtual Addressing mapping:
Map real memory to virtual addressing.
Enable the OS to manipulate application
memory addressing.
Enable fork!
-
8/14/2019 Intro_to_OS_v02
11/30
Swap file system
A Kernel driver that control the virtualmemory that is located on the hard disk. This
memory belongs to application that aresleeping. When this application arise thekernel driver will fetch their memory fromthe hard disk back to physical memory.
Work tightly with the MM component.
-
8/14/2019 Intro_to_OS_v02
12/30
Processors
Processors are object of the OS that have: stack,heap, code and data, all mapped by the OS. Each
Processors have its own CPU registers whichincludes program counter and stack pointer.
The process memory is unique and can access only
by the OS when needed.
Each Process has its user ID and all other securityIDs!
-
8/14/2019 Intro_to_OS_v02
13/30
Threads
Threads are OS objects that exist inside aprocess. Each Thread has its own registers
and stack. But share the same memory space! The process itself is then called the main
threads!
-
8/14/2019 Intro_to_OS_v02
14/30
Tasks
Exist in system that do not use memorymapping, so all process are like threads
running in one process, which is the OSitself!
In this case we call them tasks.
-
8/14/2019 Intro_to_OS_v02
15/30
Scheduler
The Scheduler is a machine inside of the kernel thatshare the CPU among all process and threads in the
system include the kernel itself! The Scheduler share the CPU by priority and byorder.
A good Scheduler can improve system
performance, and should fit the OS main purpose ofuse!
Can share two or more CPUs among processes.
-
8/14/2019 Intro_to_OS_v02
16/30
Loader
The OS has a code loader.
The loader can load kernel driver into the kernel
and application (process) into the user space. The Linux load recognize elf a.out and coff
formats.
The loader perform dynamic link to resolve all of
the new module unresolved links. In case of application to load all the libraries
required by the new application.
-
8/14/2019 Intro_to_OS_v02
17/30
Blocking and non-blocking
Blocking operation is an operation thatblocks the thread (or process) until the
condition is true. In this case the Schedulerwill move to other threads.
Blocking operation can have time-out.
non-blocking operation returns immediatelywithout waiting.
-
8/14/2019 Intro_to_OS_v02
18/30
Event
Usually Pure blocking call (could be withtimeout) for an event to happen.
An event could be for example key pressed.
In this case the thread will wait until use
press a key. (Just like this slide)
-
8/14/2019 Intro_to_OS_v02
19/30
Semaphores
When two threats or tasks use the same resource,they must use a sort of a lock mechanism. This is
the Semaphore. There are three basic kinds:
Binary semaphore lock or not.
Count semaphore can be obtain several times
before it is locked! Mutex thread depended semaphore. Can be obtain
endlessly by the same thread that lock it.
Obtain Semaphore can be blocking call or not.
-
8/14/2019 Intro_to_OS_v02
20/30
Inter process communication
Message queues.
Shared Memory
Sockets (network!)
-
8/14/2019 Intro_to_OS_v02
21/30
Message queue
Sending messages between processes,threads or tasks.
In case of threads we can pass only thepointer to a memory block. That is all needed
since they all live in the same memory space!
In case of process we should pass all themessage since there is memory sharing
between two processes.
-
8/14/2019 Intro_to_OS_v02
22/30
Shared Memory
A block of memory that can be shared byseveral processes.
This enable different processes which bydefault live each in its own memory space to
share a memory block together.
In this case a semaphore is needed to avoidaccident write by two processes to the same
memory block on the same time!.
-
8/14/2019 Intro_to_OS_v02
23/30
CPU modes
Most CPU provide at least two mode of operation(Usually there are more!)
System mode is provide for the OS for its normaloperation. This mode has full privilege and full
memory access.
User mode Application area mode. In this mode,
processes can access only their own memory, using
the virtual memory supplied by the OS.
-
8/14/2019 Intro_to_OS_v02
24/30
Kernel versa OS
Kernel contains only the area that works in systemmode (or other privilege modes as interrupt orexception modes)
The OS contains the Kernel and other component
that runs in user mode but are related to the OS
itself like the X-server, the init process.
Processors and threads can run inside the kernel,
outside as part of applications or part of the system.
-
8/14/2019 Intro_to_OS_v02
25/30
System calls (syscalls)
The bridge between kernel and outside thekernel.
Syscalls are the fastest way to invoke theunderling system
Most CPUs this day have system call for this
purpose.
-
8/14/2019 Intro_to_OS_v02
26/30
GlibC and the standard library
GNU standard library for C basedapplication.
Implement all of the C standard functions.
Use the system calls to call the underlying
OS as needed!
-
8/14/2019 Intro_to_OS_v02
27/30
POSIX standard
IEEE standard
Stand for Portable Operating System
Interface.
A standard interface to the underlying OS.
Linux today have libraries to support POSIX.
-
8/14/2019 Intro_to_OS_v02
28/30
Interrupt, and interrupt handler
Interrupt is issued by hardware on an event.
For example, the timer interrupt interrupt every few
CPU cycles or every few micro seconds. For each interrupt there is interrupt handler which is
a routine part of the OS that handles this event
process it as needed.
For example a NIC interrupt will be a network
packet that should be forward to the TCP/IP stack.
-
8/14/2019 Intro_to_OS_v02
29/30
Exceptions and exceptionshandlers
Exception are issued by the CPU when a wronginstruction is issued.
Exception could be for example, divide by zero andaccess inaccessible memory.
Each exception has its own handler, the exception
handler in case of application will create a core
dump and clear the application from the memory.
(or call the debugger directly in case of windows)
-
8/14/2019 Intro_to_OS_v02
30/30
Classification of system
multi-user : Allows two or more users to runprograms at the same time.
multiprocessing : Supports running a program onmore than one CPU.
multitasking : Allows more than one program to runconcurrently.
Embedded: special-purpose computer system,which is completely encapsulated by the device itcontrols.
real time: Responds to input instantly.