Operating Systems - A Primer

50 %
50 %
Information about Operating Systems - A Primer
Technology

Published on May 1, 2011

Author: saumilshah

Source: slideshare.net

Description

A quick introduction to Operating Systems and how OSes support process execution.

Operating Systems - A Primer

Introduction

# who am i Saumil Shah CEO Net-square. Hacker, Speaker, Trainer, Author. M.S. Computer Science Purdue University. Google: "saumil" LinkedIn: saumilshah

Preview

CPU and Registers

The CPU We shall discuss the Intel x86 32-bit CPU.

The CPU We shall discuss the Intel x86 32-bit CPU. The CPU has REGISTERS.

The CPU We shall discuss the Intel x86 32-bit CPU. The CPU has REGISTERS. "Variables" on the CPU, hard-wired. Size is equal to the "machine word". (32 bits)

What do Registers do?

What do Registers do? Registers hold data.

What do Registers do? Registers hold data. They may be numbers... ...or memory addresses (pointers)

What do Registers do? Registers hold data. They may be numbers... ...or memory addresses (pointers) Using registers, the CPU can perform computations, read and write memory, and execute instructions.

x86 Registers - the basics EAX ESI EBX EDI ECX ESP EDX EBP EIP EFLAGS there are more, but this is good enough for now.

x86 Registers - General Purpose EAX Accumulator EBX Base ECX Count EDX Data

x86 Registers - General Purpose EAX Accumulator EBX Base ECX Count EDX Data Used for Integer operations (arithmetic), returning values (EAX), loops (ECX), or anything the compiler wishes to use them for.

x86 Registers - Pointers ESI Source Index EDI Destination Index

x86 Registers - Pointers ESI Source Index EDI Destination Index These are POINTERS, used for block copy operations. ESI = address of source, EDI = address of destination, ECX = count of bytes/words to be copied.

x86 Registers - Stack Related Stack Pointer ESP Frame Pointer (Base Pointer) EBP

x86 Registers - Stack Related Stack Pointer points to the top of the process stack. Stack Pointer ESP Frame Pointer (Base Pointer) EBP

x86 Registers - Stack Related Stack Pointer points to the top of the process stack. Stack Pointer ESP Frame Pointer (Base Pointer) EBP Frame pointer points to FRAMES within the stack. Frames store data for functions.

x86 Registers - EIP EIP Instruction Pointer (program counter)

x86 Registers - EIP A very important register. Points to a memory address from where the CPU fetches and executes the next instruction. EIP autoincrements after every instruction. EIP Instruction Pointer (program counter)

x86 Registers - Flags EFLAGS Bit Flags

x86 Registers - Flags Individual bits indicate status of operations. Boolean values. Never treated as a full register, just individual bit flags. EFLAGS Bit Flags

Operating System Basics

The Operating System Modern Operating Systems are very complex and do many things. We shall discuss only the basic concepts and functions of an OS.

The Operating System Modern Operating Systems are very complex and do many things. We shall discuss only the basic concepts and functions of an OS. Multitasking and Multiprogramming Processes The Virtual Machine

What is Multiprogramming?

What is Multiprogramming? The ability to store and execute multiple programs in the memory

What is Multiprogramming? The ability to store and execute multiple programs in the memory ...and what is Multitasking?

What is Multiprogramming? The ability to store and execute multiple programs in the memory ...and what is Multitasking? Running multiple PROCESSES at the SAME TIME.

So what is a "Process"?

So what is a "Process"? A PROCESS is termed as a program that is EXECUTING. A running program.

So what is a "Process"? A PROCESS is termed as a program that is EXECUTING. A running program. A process is an instance of a program. Processes "live" in memory. Programs live on disk. (secondary storage) A program may have multiple processes of its own self.

How do multiple processes run simultaneously?

How do multiple processes run simultaneously? By TIME SLICING and CONTEXT-SWITCHING

How do multiple processes run simultaneously? By TIME SLICING and CONTEXT-SWITCHING Each process runs for a short time and is then PRE-EMPTED to let another process run. This happens so fast, it appears as if all processes are running simultaneously. This is called MULTITASKING

Processes and Multitasking

Multitasking Process Queue P2 P3 P4 P1 CPU Process P1 is running. It shall continue to run for a small period of time, called a QUANTUM.

Multitasking P2 P3 P4 P1 Time Slice Interrupt CPU An INTERRUPT is triggered at the end of the quantum. A snapshot of P1's registers (P1's CONTEXT) is saved.

Multitasking P2 P3 P4 P1 CPU P1 is then PRE-EMPTED. It is brought back into the process queue.

Multitasking P2 P3 P4 P1 CPU It is P2's turn now. P2's context is loaded into the CPU's registers. This is called CONTEXT SWITCHING.

Multitasking P1 P3 P4 P2 CPU P2 is scheduled to execute on the CPU.

Multitasking P1 P3 P4 P2 CPU P2 runs for the next quantum.

Multitasking P1 P3 P4 P2 Time Slice Interrupt CPU P2's context is now saved.

Multitasking P1 P3 P4 P2 CPU P2 is PRE-EMPTED. It is brought back into the process queue. Next it will be P3's turn, and so on.

Virtual Machines and Process Memory Maps

What is a Virtual Machine?

What is a Virtual Machine? A view of ABSTRACTED HARDWARE as presented to a PROCESS by the OS.

What is a Virtual Machine? A view of ABSTRACTED HARDWARE as presented to a PROCESS by the OS. A process sees its OWN view of the CPU, Memory, Storage, and other devices. Every process runs in its own "virtual" machine. This is how the OS ensures process memory and resource segregation.

Do processes have their OWN view of the memory? Yes. Processes see "Virtual Memory"

Do processes have their OWN view of the memory? Yes. Processes see "Virtual Memory" Physical memory is divided into PAGES. A process is assigned pages as needed. This is done by the Memory Management Unit (MMU) From the process' point of view, it seems to have all the memory to itself.

Pages from P1's memory are mapped from physical memory. P1 sees a "virtual address space". Physical Memory P1's memory Physical and Virtual Memory

Physical and Virtual Memory Similarly for P2. Physical Memory P1's memory P2's memory

Can one process access another's memory? No. A process can only access its own virtual memory space.

Can one process access another's memory? No. A process can only access its own virtual memory space. A process CANNOT access physical memory.

The Process' view of memory Process Memory has its own VIRTUAL ADDRESS SPACE. Typically 2 to 3 GB. Binary Heap It is called a PROCESS MEMORY MAP. Lib 3GB (Linux) 2GB (Win32) Lib Lower addresses represented at the top of the map. Higher addresses at the bottom. Lib Stack Process' Virtual Memory

Linux Process Memory Map 0x08000000 Binary Heap Lib 3GB Lib Lib Stack 0xbfffffff Linux Process Memory Map

An example Here's how to view a process' memory map in Linux. The process here is PID 1110. saumil@localhost:$ pmap 1110 1110: /home/nweb/nweb 8181 /home/nweb 08048000 8K read/exec /home/nweb/nweb 0804a000 4K read/write /home/nweb/nweb 0804b000 8K read/write/exec [ anon ] 40000000 72K read/exec /lib/ld-2.3.1.so 40012000 4K read/write /lib/ld-2.3.1.so 40013000 4K read/write [ anon ] 40019000 1204K read/exec /lib/i686/libc-2.3.1.so 40146000 16K read/write /lib/i686/libc-2.3.1.so 4014a000 8K read/write [ anon ] bfffe000 8K read/write/exec [ anon ] total 1336K

The Big Picture

CPU NIC Storage Physical Memory

File System Network Stack Scheduler MMU Driver Driver CPU NIC Storage Physical Memory

kernel space System Calls File System Network Stack Loader Scheduler MMU Driver Driver CPU NIC Storage Physical Memory

user space Virtual Memory PROCESS Virtual Memory PROCESS Virtual Memory PROCESS CPU FS N/W CPU FS N/W CPU FS N/W kernel space System Calls File System Network Stack Loader Scheduler MMU Driver Driver CPU NIC Storage Physical Memory

user space Virtual Memory PROCESS Virtual Memory PROCESS Virtual Memory PROCESS CPU FS N/W CPU FS N/W CPU FS N/W kernel space System Calls File System Network Stack Loader Scheduler MMU Driver Driver CPU NIC Storage Physical Memory

Key Concepts

Review

END

Add a comment

Related presentations

Related pages

Architectures and Operating Systems: A Primer

Let's Just Call Them Up: Building Packages for Multiple Prev: Building Packages for Multiple Architectures and Operating Systems: A Primer From a software ...
Read more

History of operating systems - Wikipedia, the free ...

History of operating systems This article needs additional citations for ... Operating systems; Programming languages; Software engineering; Modern concepts;
Read more

Networking Primer: Desktop Operating Systems | Micro Focus

Each workstation on the network must have desktop operating system software that manages the interaction between the workstation's applications and its ...
Read more

What is an Operating System (OS)? Webopedia Definition

An operating system (OS) is the most important program that runs on a computer. Computers and mobile devices must have an operating system to run programs.
Read more

Architectures and Operating Systems: A Primer

Architectures and Operating Systems: A Primer From a software engineering standpoint, there are only two major differences between any two computer systems:
Read more

Module 10: Unix Primer - NPTEL

Operating Systems/Unix Primer Lecture Notes PCP Bhatt/IISc, Bangalore ...
Read more

Top Ten Best Operating Systems - TheTopTens

Top Ten Best Operating Systems. eddie ie. Linux - fedora, ubuntu etc..., Mac, Windows - XP, Vista etc... The Top TenXW. 1Microsoft Windows 7.
Read more

Usage share of operating systems - Wikipedia, the free ...

The usage share of operating systems is the percentage of the operating systems used in computers. Different categories of computers use a wide variety of ...
Read more

Embedded Linux Primer: A Practical Real-World Approach ...

Buy Embedded Linux Primer: A Practical Real-World Approach (2nd Edition) on Amazon.com FREE SHIPPING on qualified orders
Read more