Threads, System Calls, and Thread Switching

Size: px
Start display at page:

Download "Threads, System Calls, and Thread Switching"

Transcription

1 µ-kernel Construction (2) Threads, System Calls, and Thread Switching (updated on )

2 Review from Last Lecture

3 The 100-µs Disaster 25 MHz MHz MHz Pentium 133 MHz Alpha 3

4 C Costs (486, 50 MHz) [µs] Mach [µs] 400 Mach L msg len L4 0 raw copy msg len 4

5 Analysis Mach uses asynchronous C Data buffered in kernel Cache destruction, infinite resources Memory oybus traffic Workplace OS switched to synchronous C Performance still horrible Why? Microkernel construction is difficult! 5

6 Size Comparison Mach 4 x86: 90,000 Xen 2.0 hypervisor: 45,000 L4Ka::Pistachio x86: 45,000 6

7 Threads and How to Switch Them

8 Fundamental Abstractions Thread Address space What is a thread? How to implement it? What conclusions can we draw from our analysis with rect to µ-kernel construction? 8

9 Fundamental Abstractions A thread is an independent flow of control inside an address space. Threads are identified by unique identifiers and communicate via C. Threads are characterized by a set of registers, including at least an instructioni pointer, a stack pointer and state information. A thread s state also includes the address space in which the thread currently executes. 9

10 Thread Properties Regs Memory Internal properties External properties Register set General purpose registers,, and Stack Status Flags, privilege, etc. OS-specific state Priority, time, etc. Address space Unique ID Communication status 10

11 Construction Conclusion Thread state must be saved/restored on thread switch We need a Thread Control Block (TCB) per thread TCBs must be kernel objects TCBs implement threads We often need to find Any thread s TCB using its global ID The currently executing thread s TCB (per processor) At least partially. We have found some good reasons to implement parts of the TCB in user memory ( local C). 11

12 Thread Switch A B Processor tcb A user mode A Memory tcb B 12

13 Thread Switch A B Processor tcb A user mode A kernel Memory tcb B 13

14 Thread Switch A B Processor tcb A user mode A kernel Memory tcb B 14

15 Thread Switch A B Processor tcb A user mode A kernel Memory tcb B 15

16 Thread Switch A B Processor tcb A user mode A kernel user mode B Memory tcb B 16

17 Thread Switch A B Thread A is running in user mode Thread A experiences its end of time slice or is preempted by a (device) interrupt We enter kernel mode The microkernel saves the status of thread A on A s TCB The microkernel loads the status of thread B from B s TCB We leave kernel mode Thread B is running in user mode 17

18 Thread Switch A kernel B Processor tcb A user mode A Memory 18

19 Thread Switch A kernel B Processor? tcb A user mode A kernel Memory 19

20 Thread Switch A kernel B Processor Kernel code Kernel stack tcb A user mode A kernel Memory 20

21 Thread Switch A kernel B Processor Kernel code Kernel stack tcb A user mode A kernel Memory 21

22 Thread Switch A kernel B Processor Kernel code Kernel stack tcb A user mode A kernel Memory 22

23 Thread Switch A kernel B Processor Kernel code tcb A Kernel stack user mode A kernel Memory 23

24 Thread Switch A kernel B Processor Kernel code tcb A Kernel stack user mode A kernel tcb B Memory Kernel stack 24

25 Thread Switch A kernel B Processor Kernel code tcb A Kernel stack user mode A kernel tcb B Memory Kernel stack 25

26 Construction Conclusion From the view of the designer there are two alternatives: Single Kernel Stack Only one stack is used in kernel mode all the time Per-Thread Kernel Stack Each thread has its own stack in kernel mode 26

27 Single Kernel Stack Per processor, event model Either continuations Complex to program Or stateless kernel No kernel threads, kernel not interruptible, difficult to program Structurally inefficient system calls + Kernel can be exchanged on-the-fly E.g. the fluke kernel from Utah Low cache footprint The same stack is always used! 27

28 Per-Thread Kernel Stack Thread model Simple, elegant, flexible Conclusion: We have to look for a solution that minimizes the kernel stack size Kernel can always use threads, no special methods required for keeping state while interrupted/blocked No conceptual difference between kernel mode and user mode Larger cache footprint Difficult to exchange kernel on-the-fly Conclusion: Either no persistent TCBs or TCBs must hold symbolic addresses 28

29 Kernel Entry and Exit on IA-32

30 Kernel Entry (IA-32) CPU eflags eax ebx ecx edx ebp esi edi user mode tcb A kernel code user stack 0 Trap/fault occurs (int n / exception / interrupt) points to the currently running thread s kernel stack 30

31 Kernel Entry (IA-32) CPU eflags eax ebx ecx edx ebp esi edi kernel mode tcb A kernel code ss user stack 0 Trap/fault occurs (int n / exception / interrupt) Push user SS:E onto kernel stack, load kernel SS:E 31

32 Kernel Entry (IA-32) CPU eflags eax ebx ecx edx ebp esi edi kernel mode tcb A kernel code flg ss user stack 0 Trap/fault occurs (int n / exception / interrupt) Push user SS:E onto kernel stack, load kernel SS:E Push user E, reset flags (I := 0, CPL := 0) 32

33 Kernel Entry (IA-32) CPU eflags eax ebx ecx edx ebp esi edi kernel mode tcb A kernel code cs flg ss user stack 0 Trap/fault occurs (int n / exception / interrupt) Push user SS:E onto kernel stack, load kernel SS:E Push user E, reset flags (I := 0, CPL := 0) Push user CS:E, load kernel entry CS:E 33

34 Kernel Entry (IA-32) CPU eflags eax ebx ecx edx ebp esi edi kernel mode tcb A X kernel code cs flg ss user stack 0 Trap/fault occurs (int n / exception / interrupt) Push user SS:E onto kernel stack, load kernel SS:E Push user E, reset flags (I := 0, CPL := 0) Push user CS:E, load kernel entry CS:E Push X: error code (hw, at exception) or kernel-call type hardware programmed, single instruction 34

35 Kernel Entry (IA-32) CPU eflags eax ebx ecx edx ebp esi edi kernel mode tcb A edi eax X kernel code cs flg ss user stack 0 Trap/fault occurs (int n / exception / interrupt) Push user SS:E onto kernel stack, load kernel SS:E Push user E, reset flags (I := 0, CPL := 0) Push user CS:E, load kernel entry CS:E Push X: error code (hw, at exception) or kernel-call type Push registers (optional) hardware programmed, single instruction 35

36 System Call (IA-32) int $0x32 push $X pusha Error code, e.g., 3 means page fault Push all the register content to the stack User mode Kernel mode popa addl $4, % iret Pop all registers E := E + 4 Restore the old E, discard error code $X Interrupt return: single instruction that restores user SS:E and CS:E from kernel stack 36

37 Kernel Stack State Uniprocessor: Any kernel stack myself is up-to-date! myself s kernel stack is up-to-date when in kernel mode except for brief moment. One thread running All the others in their kernel-state We can analyze their kernel stacks (e.g., L4 ExchangeRegisters(), kdb) All processes except the one running are in kernel mode tcb edi eax 3 cs flg ss 37

38 Kernel Stack State Uniprocessor: Any kernel stack myself is up-to-date! myself s kernel stack is up-to-date when in kernel mode except for brief moment. X permits to differentiate between stack layouts Interrupt, exception, some system calls C V86 mode tcb edi eax 4 cs flg ss ds es fs gs tcb 5 cs flg ss tcb edi eax 3 cs flg ss 38

39 Kernel Stack State Uniprocessor: Any kernel stack myself is up-to-date! myself s kernel stack is up-to-date when in kernel mode except for brief moment. X permits to differentiate between stack layouts Interrupt, exception, some system calls C V86 mode tcb edi eax 4edi eax cs flg 4 ss ds cs es flg fs gs ss ds es fs gs tcb 5 cs flg ss tcb edi eax 3 cs flg ss 39

40 Thread Switch on IA-32

41 Locating the TCB Remember: We need to find Any thread s TCB using its global ID The currently executing thread s TCB Next lecture Kernel E Align TCBs: movl %, %ebp andl -sizeof_tcb, %ebp tcb 0 41

42 Thread Switch (IA-32) Thread A int $0x32 pushl $X pusha movl %, %ebp andl -sizeof_tcb, %ebp /* edi == address of B s TCB */ movl %, OFF_E(%ebp) movl OFF_E(%edi), % addl sizeof_tcb, %edi movl %edi, 0 Switch current kernel stack pointer Thread B Switch E0 so that next kernel entry uses new kernel stack popa addl iret $4, % int $0x32 42

43 Switching Threads (IA-32) CPU eflags tcb tcb edi eax Kernel code X cs flg ss 0 eax ebx ecx edx ebp esi edi user stack user stack int $0x32 43

44 Switching Threads (IA-32) CPU eflags tcb tcb edi eax Kernel code X cs cs flg flg ss ss 0 eax ebx ecx edx ebp esi edi user stack user stack int $0x32 44

45 Switching Threads (IA-32) CPU eflags tcb tcb edi eax edi eax Kernel code X X cs cs flg flg ss ss 0 eax ebx ecx edx ebp esi edi user stack user stack int $0x32, push registers of blue thread 45

46 Switching Threads (IA-32) CPU eflags tcb tcb edi eax edi eax Kernel code X X cs cs flg flg ss ss 0 eax ebx ecx edx ebp esi edi user stack user stack int $0x32, push registers of blue thread Switch kernel stacks (store and load E) 46

47 Switching Threads (IA-32) CPU eflags tcb tcb edi eax edi eax Kernel code X X cs cs flg flg ss ss 0 eax ebx ecx edx ebp esi edi user stack user stack int $0x32, push registers of blue thread Switch kernel stacks (store and load E) Set E0 to new kernel stack 47

48 Switching Threads (IA-32) CPU eflags tcb tcb edi eax Kernel code X cs cs flg flg ss ss 0 eax ebx ecx edx ebp esi edi user stack user stack int $0x32, push registers of blue thread Switch kernel stacks (store and load E) Set E0 to new kernel stack Pop red registers 48

49 Switching Threads (IA-32) CPU eflags tcb tcb edi eax Kernel code X cs flg ss 0 eax ebx ecx edx ebp esi edi user stack user stack int $0x32, push registers of blue thread Switch kernel stacks (store and load E) Set E0 to new kernel stack Pop red registers, return to red user thread (iret) 49

50 Fast System Calls on IA-32

51 Syscalls via int n are too slow int n touches too much memory (cache, TLB) Save user mode CS:E, SS:E, E Load kernel mode SS0:E0 (from TSS) Load kernel mode CS:E (from IDT) Does too much (microcode) Segmentation not used today Many checks could be avoided 51

52 Sysenter/sysexitsysexit (IA-32) Model Specific Register (MSR) Kernel Kernel Flat 4 GB segments Kernel 4 GB Sysenter E := MSR[Kernel ] E := MSR[Kernel ] EFlags.I := 0, CPL := 0 Interrupts off Sysexit E := ECX E := EDX CPL := 3 Enter kernel mode User 0 GB 52

53 Sysenter/sysexitsysexit (IA-32) Model Specific Register (MSR) Kernel Kernel Flat 4 GB segments Kernel 4 GB Sysenter E := MSR[Kernel ] E := MSR[Kernel ] EFlags.I := 0, CPL := 0 User has to provide current user and By convention (e.g., ECX, EDX) User Flags undefined Sysexit E := ECX E := EDX CPL := 3 Kernel has to re-enable interrupts 0 GB 53

54 Sysenter/sysexitsysexit and int n Emulate effects of int instruction after sysenter (assuming ECX=U, EDX=U) subl $20, % movl %ecx, 16(%) movl %edx, 4(%) movl $5, (%) iret instruction movl 16(%), %ecx movl 4(%), %edx sti sysexit Emulate iret E tcb 5 cs flg ss 54

55 Sysenter/sysexitsysexit and int n Emulate effects of int instruction after sysenter (assuming ECX=U, EDX=U) movl (%), % subl $20, % movl %ecx, 16(%) movl %edx, 4(%) movl $5, (%) iret instruction movl 16(%), %ecx movl 4(%), %edx sti sysexit Emulate iret Trick: MSR points to TSS.0 + Avoids slow updates of the MSR + Update only TSS.0 on address space switch + Keeps MSR (used by sysenter) and TSS.0 (used otherwise) in sync - Requires memory access tcb 5 cs flg ss 55

56 Case study: Itanium (aka IA-64) Thread Switching and Kernel Entry

57 IA-64 User Accessible Registers General Registers Floating-point Registers Predicates Branch Registers Application Registers gr 0 gr 1 gr fr 0 fr 1 fr pr 0 pr 1 pr 2 pr 63 1 br 0 br 1 br 2 br 7 63 Instruction Pointer 63 Current Frame Marker 63 5 CFM User Mask ar 0 ar 7 ar 16 ar 17 ar 18 ar 19 ar 21 ar 24 ar 25 ar 26 ar 27 ar 28 ar 29 ar 30 ar 32 ar 36 ar 40 ar 44 ar 64 ar 65 ar KR0 KR7 RSC B BSTORE RNAT FCR EFLAG CSD SSD CFLG FSR FIR FDR CCV UNAT FPSR ITC PFS LC EC 0 gr 127 fr 127 ar

58 Thread Switching Overhead General Registers Floating-point Registers Predicates Branch Registers Application Registers All registers must be saved on context ar 0 KR gr 0 gr 1 gr fr switches 0 fr 1 fr 2 pr 0 pr 1 pr 2 More than 3.2 kb br 0 br 1 br 2 ar 7 KR7 RSC B BSTORE RNAT FCR EFLAG CSD SSD CFLG FSR FIR FDR CCV UNAT FPSR ITC PFS LC EC ar 16 ar 3.2 kb of register contents 17 ar 18 ar 19 br 7 ar 21 ar 24 ar 25 Instruction Pointer ar ar 27 ar 28 ar 29 pr 63 Current Frame Marker ar ar 32 CFM ar 36 ar 40 User Mask ar ar 64 ar 65 ar 66 Certain optimizations made possible by hardware gr 127 fr 127 ar

59 Thread Switching Overhead gr 0 gr 1 gr 2 General Registers fr 0 fr 1 fr 2 Floating-point Registers Static Registers gr 0 gr 31 Stacked Registers gr 32 gr 127 Predicates gr 0 fixed Branch Registers to zero Application Registers pr 0 1 br 0 ar 0 KR0 pr 1 On br 1 thread switch pr 2 br ar 2 7 KR7 ar 16 RSC ar 17 B ar 18 BSTORE ar 19 RNAT ar br 21 FCR 7 ar EFLAG Stacked registers 24 ar 25 CSD Instruction Pointer ar 26 SSD 63 0 ar 27 CFLG ar 28 FSR ar 29 FIR pr 63 Current Frame Marker ar 30 FDR 63 0 ar 32 CCV CFM ar 36 UNAT ar 40 FPSR Only User 2.5 Mask kb ar 44 ITC 5 0 ar 64 PFS contents left ar 65 LC EC 0 Static registers must be saved explicitly handled by register stack engine (RSE) 2.5 kb of register ar 66 0 gr 127 fr 127 ar

60 Thread Switching Overhead gr 0 gr 1 gr 2 General Registers fr 0 fr 1 fr 2 Floating-point Registers Predicates fr 0 and Branch Registers fr 1 fixedapplication Registers pr 0 1 br 0 ar 0 KR0 pr 1 Remaining br 1 floating- pr 2 br ar 2 7 KR7 ar 16 RSC ar 17 B ar 18 BSTORE handled lazily ar 19 RNAT ar br FCR Only 7 28 (of 128) 21 ar 24 EFLAG ARs ar 25 CSD implemented Instruction Pointer ar 26 SSD 63 0 ar 27 CFLG 28 FSR Only ~0.5 kbar 29 offir pr 63 Current Frame Marker ar 30 FDR register 63 contents 0 ar 32 left CCV CFM ar 36 UNAT ar 40 FPSR User Mask ar 44 ITC 5 0 ar 64 PFS ar 65 LC EC point registers can be ar 66 gr 127 fr 127 ar

61 Thread Switch Example [pistachio/kernel/include/glue/v4-ia64/tcb.h] asm volatile ( "r_bsp = r14 \n" "r_ip = r15 \n" "r_rp = r16 \n" "r_cfm = r17 \n" "r_pfs = r18 \n" "r_rnat = r19 \n" "r_unat = r20 \n" "r_pr = r21 \n" "r_psr = r22 \n" "new_stack = r31 \n" "sp1 = r10 \n" "sp2 = r11 \n" " \n" " // Move context into general registers \n" " mov r_pfs = ar.pfs \n" " mov r_rp = rp \n" " movl r_ip = 2f \n" " \n" " // Make stacked reg is not used \n" sure that " mov new_stack = %[dest_stack] \n" " \n" " // Allocate frame \n" for switch " add sp \n" = -%[sizeof_ctx],sp ;; " ;; \n" " mov ar.rsc = 0 \n" " add sp1 = %[offset_pfs], sp \n" " add sp2 = %[offset_pfs]+8,sp \n" " st8 [%[this_stack_ptr]] stack = sp \n" " \n" " // Set for new thread \n" thread ids and ksp " mov "MKSTR(r_GLOBAL_ID)" = %[dest_gid] \n" " mov "MKSTR(r_LOCAL_ID) " = %[dest_lid] \n" " mov "MKSTR(r_KERNEL_)" = %[dest_stack_top] \n" " mov "MKSTR(r_PHYS_TCB_ADDR)" = %[dest_tcb_phys] \n" " \n" " // Set region id \n" " mov rr[r0] = %[dest_rid] \n" " \n" " // Make a call so can get CFM \n" that we " br.call.sptk.many rp = 1f \n" " \n" " // Store context into switch frame \n" "1: alloc r_cfm = \n" ar.pfs, 0, 0, 0, 0 " ;; \n" " mov r_bsp = ar.bsp \n" " flushrs \n" " ;; \n" " \n" " st8 [sp1] = r_pfs, 16 \n" " st8 [sp2] = r_cfm, 16 \n" " mov r_unat = ar.unat \n" " mov r_rnat = ar.rnat \n" " mov r_pr = pr \n" " mov r_psr = psr \n" " ;; \n" " st8 [sp1] = r_ip, 16 \n" " st8 [sp2] = r_bsp, 16 \n" ;; \n " st8 [sp1] = r_rnat, 16 \n" " st8 [sp2] = r_unat, 16 \n" " ;; \n" " st8 [sp1] = r_pr \n" " st8 [sp2] = r_psr, 16 \n" " invala \n" " loadrs \n" " ;; \n" " st8 [sp2] = r_rp \n" " \n " // Get new switch frame \n" " add sp1 = %[offset_pfs], new_stack \n" " add sp2 = %[offset_pfs]+8,new_stack \n" " ;; \n" " \n" " // Load context from new frame \n" " ld8 r_pfs = \n" [sp1], 16 " ld8 r_cfm = [sp2], 16 \n" " ;; \n" " ld8 r_ip = [sp1], 16 \n" " ld8 r_bsp = [sp2], 16 \n" " mov ar.pfs = r_cfm \n" " ;; \n" " ld8 r_rnat = [sp1], 16 \n" " ld8 r_unat = [sp2], 16 \n" " mov ar.bspstore = r_bsp \n" " ;; \n" " ld8 r_pr = [sp1] \n" " ld8 r_psr = [sp2], 16 \n" " mov ar.rnat = r_rnat \n" " mov ar.unat = r_unat \n" " ;; \n" " ld8 r_rp = [sp2] \n" " mov rp = r_ip \n" " add sp = %[sizeof_ctx],new_stack \n" " mov pr = r_pr, 0x1ffff \n" " mov psr.l = r_psr \n" " ;; \n" " srlz.d \n" " ;; \n" " br.ret.sptk.many rp \n" " \n" "2: // Restore non-clobberable registers \n" " mov ar.pfs = r_pfs \n" " mov rp = r_rp \n" " mov ar.rsc = 3 \n" " ;; \n" : : [this_stack_ptr] "r" (&this->stack), [dest_stack] "r" (dest->stack), [sizeof_ctx] "i" (sizeof (ia64_switch_context_t)), [offset_pfs] "i" (offsetof (ia64_switch_context_t, pfs)), [dest_gid] "r" (dest->get_global_id ().get_raw ()), [dest_lid] "r" (dest->get_local_id ().get_raw ()), [dest_stack_top] "r" (dest->get_stack_top ()), [dest_tcb_phys] "r" (dest->arch.phys_addr), ((dest->space->get_region_id () << 8) + (12 << [dest_rid] "r" 2)) : CALLER_SAVED_REGS, CALLEE_SAVED_REGS, "memory"); 61

62 Exception Handling gr 0 gr 1 gr 2 General Registers fr 0 fr 1 fr 2 Floating-point Registers Banked Registers gr 16 gr 31 Predicates Bank Branch 1 Registers used normally Application Registers pr 0 1 br 0 ar 0 KR0 pr 1 Automatic br 1 switch to bank 0 pr 2 br ar 2 7 KR7 on exceptions ar 16 RSC ar 17 B ar 18 BSTORE Frees up registers ar 19 RNAT for ar br FCR storing 7 context 21 ar 24 EFLAG t ar 25 CSD Instruction Pointer ar 26 SSD Can switch manually 63 0 ar 27 CFLG ar 28 FSR ar 29 FIR pr 63 Current Frame Marker ar 30 FDR 63 0 ar 32 CCV CFM ar 36 UNAT ar 40 FPSR User Mask ar 44 ITC 5 0 ar 64 PFS ar 65 LC EC ar 66 gr 127 fr 127 ar

63 Exception Handling General Registers Backing Store Run on bank 1 gr 0 gr 1 gr Exception Switches to bank 0 Store other registers gr

64 Exception Handling gr 0 gr 1 gr 2 General Registers Backing Store Run on bank Exception Switches to bank 0 Store other registers Switch to bank 1 Store remaining registers Must not receive interrupts or raise exceptions while storing exception context gr

65 Kernel Entry Kernel entry by exception is slow Must flush instruction pipeline IA-64 provides an epc instruction Raises privileges to kernel mode Continues execution on next instruction Can only be executed in special regions of virtual memory 65

66 System Call Trampoline User call ipc ipc: epc call ipc return Kernel ipc: 66

67 System Call Trampoline for IA-32 Is it useful? Yes! Kernel dictates trampoline code Kernel can offer best kernel entry method (e.g., sysenter/sysexit if supported by CPU) Some system calls can execute entirely in user-mode (e.g., reading current time) Used in L4Ka::Pistachio Other systems are starting to use system call trampolines (e.g., Linux 2.6) 67

µ-kernel Construction

µ-kernel Construction µ-kernel Construction Fundamental Abstractions Thread Address Space What is a thread? How to implement? What conclusions can we draw from our analysis with respect to µk construction? Fundamental Abstractions

More information

IPC Functionality & Interface Universität Karlsruhe, System Architecture Group

IPC Functionality & Interface Universität Karlsruhe, System Architecture Group µ-kernel Construction (4) IPC Functionality & Interface 1 IPC Primitives Send to (a specified thread) Receive from (a specified thread) Two threads communicate No interference from other threads Other

More information

µ-kernel Construction

µ-kernel Construction µ-kernel Construction Fundamental Abstractions Thread Address Space What is a thread? How to implement? What conclusions can we draw from our analysis with respect to µk construction? A thread of control

More information

8/09/2006. µ-kernel Construction. Fundamental Abstractions. Thread Switch A B. Thread Switch A B. user mode A kernel. user mode A

8/09/2006. µ-kernel Construction. Fundamental Abstractions. Thread Switch A B. Thread Switch A B. user mode A kernel. user mode A Fundamental Abstractions µ- Construction Thread Address Space What is a thread? How to implement? What conclusions can we draw from our analysis with rect to µk construction? A thread of control has internal

More information

µ-kernel Construction (12)

µ-kernel Construction (12) µ-kernel Construction (12) Review 1 Threading Thread state must be saved/restored on thread switch We need a Thread Control Block (TCB) per thread TCBs must be kernel objects TCBs implement threads We

More information

Multiprocessor Solution

Multiprocessor Solution Mutual Exclusion Multiprocessor Solution P(sema S) begin while (TAS(S.flag)==1){}; { busy waiting } S.Count= S.Count-1 if (S.Count < 0){ insert_t(s.qwt) BLOCK(S) {inkl.s.flag=0)!!!} } else S.flag =0 end

More information

Microkernel Construction

Microkernel Construction Microkernel Construction Kernel Entry / Exit Nils Asmussen 05/04/2017 1 / 45 Outline x86 Details Protection Facilities Interrupts and Exceptions Instructions for Entry/Exit Entering NOVA Leaving NOVA 2

More information

µ-kernel Construction

µ-kernel Construction µ-kernel Construction Fundamental Abstractions Thread Address Space What is a thread? How to implement? What conclusions can we draw from our analysis with respect to µk construction? Processor? IP SP

More information

Microkernel Construction

Microkernel Construction Kernel Entry / Exit SS2013 Control Transfer Microkernel User Stack A Address Space Kernel Stack A User Stack User Stack B Address Space Kernel Stack B User Stack 1. Kernel Entry (A) 2. Thread Switch (A

More information

Tutorial 10 Protection Cont.

Tutorial 10 Protection Cont. Tutorial 0 Protection Cont. 2 Privilege Levels Lower number => higher privilege Code can access data of equal/lower privilege levels only Code can call more privileged data via call gates Each level has

More information

19/09/2008. µ-kernel Construction. Fundamental Abstractions. user mode A kernel. user mode A kernel. user mode A kernel. user mode A kernel

19/09/2008. µ-kernel Construction. Fundamental Abstractions. user mode A kernel. user mode A kernel. user mode A kernel. user mode A kernel Fundamental Abstractions µ- Construction Thread Address Space What is a thread? How to implement? What conclusions can we draw from our analysis with rect to µk construction? Processor? A Processor code

More information

19/09/2008. Microkernel Construction. IPC - Implementation. IPC Importance. General IPC Algorithm. IPC Implementation. Short IPC

19/09/2008. Microkernel Construction. IPC - Implementation. IPC Importance. General IPC Algorithm. IPC Implementation. Short IPC IPC Importance Microkernel Construction IPC Implementation General IPC Algorithm Validate parameters Locate target thread if unavailable, deal with it Transfer message untyped - short IPC typed message

More information

Function Calls COS 217. Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site)

Function Calls COS 217. Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site) Function Calls COS 217 Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site) 1 Goals of Today s Lecture Finishing introduction to assembly language o EFLAGS register

More information

Mechanisms for entering the system

Mechanisms for entering the system Mechanisms for entering the system Yolanda Becerra Fontal Juan José Costa Prats Facultat d'informàtica de Barcelona (FIB) Universitat Politècnica de Catalunya (UPC) BarcelonaTech 2017-2018 QP Content Introduction

More information

IA32 Intel 32-bit Architecture

IA32 Intel 32-bit Architecture 1 2 IA32 Intel 32-bit Architecture Intel 32-bit Architecture (IA32) 32-bit machine CISC: 32-bit internal and external data bus 32-bit external address bus 8086 general registers extended to 32 bit width

More information

TCBs and Address-Space Layouts Universität Karlsruhe, System Architecture Group

TCBs and Address-Space Layouts Universität Karlsruhe, System Architecture Group µ-kernel Construction (3) TCBs and Address-Space Layouts 1 Thread Control Blocks (TCBs) 2 Fundamental Abstractions Thread Address space What is a thread? How to implement it? 3 Construction Conclusion

More information

Assembly Language: Function Calls

Assembly Language: Function Calls Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems: Calling and returning Passing parameters Storing local variables Handling registers without interference

More information

ICS143A: Principles of Operating Systems. Midterm recap, sample questions. Anton Burtsev February, 2017

ICS143A: Principles of Operating Systems. Midterm recap, sample questions. Anton Burtsev February, 2017 ICS143A: Principles of Operating Systems Midterm recap, sample questions Anton Burtsev February, 2017 Describe the x86 address translation pipeline (draw figure), explain stages. Address translation What

More information

Assembly Language: Function Calls" Goals of this Lecture"

Assembly Language: Function Calls Goals of this Lecture Assembly Language: Function Calls" 1 Goals of this Lecture" Help you learn:" Function call problems:" Calling and returning" Passing parameters" Storing local variables" Handling registers without interference"

More information

Assembly Language: Function Calls" Goals of this Lecture"

Assembly Language: Function Calls Goals of this Lecture Assembly Language: Function Calls" 1 Goals of this Lecture" Help you learn:" Function call problems:" Calling and urning" Passing parameters" Storing local variables" Handling registers without interference"

More information

Assembly Language: Function Calls. Goals of this Lecture. Function Call Problems

Assembly Language: Function Calls. Goals of this Lecture. Function Call Problems Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems: Calling and urning Passing parameters Storing local variables Handling registers without interference Returning

More information

UMBC. contain new IP while 4th and 5th bytes contain CS. CALL BX and CALL [BX] versions also exist. contain displacement added to IP.

UMBC. contain new IP while 4th and 5th bytes contain CS. CALL BX and CALL [BX] versions also exist. contain displacement added to IP. Procedures: CALL: Pushes the address of the instruction following the CALL instruction onto the stack. RET: Pops the address. SUM PROC NEAR USES BX CX DX ADD AX, BX ADD AX, CX MOV AX, DX RET SUM ENDP NEAR

More information

Machine-level Representation of Programs. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Machine-level Representation of Programs. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Machine-level Representation of Programs Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Program? 짬뽕라면 준비시간 :10 분, 조리시간 :10 분 재료라면 1개, 스프 1봉지, 오징어

More information

W4118: PC Hardware and x86. Junfeng Yang

W4118: PC Hardware and x86. Junfeng Yang W4118: PC Hardware and x86 Junfeng Yang A PC How to make it do something useful? 2 Outline PC organization x86 instruction set gcc calling conventions PC emulation 3 PC board 4 PC organization One or more

More information

CSE 153 Design of Operating Systems Fall 18

CSE 153 Design of Operating Systems Fall 18 CSE 153 Design of Operating Systems Fall 18 Lecture 2: OS model and Architectural Support Last time/today l Historic evolution of Operating Systems (and computing!) l Today: We start our journey in exploring

More information

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam Assembly Language Lecture 2 - x86 Processor Architecture Ahmed Sallam Introduction to the course Outcomes of Lecture 1 Always check the course website Don t forget the deadline rule!! Motivations for studying

More information

+ Overview. Projects: Developing an OS Kernel for x86. ! Handling Intel Processor Exceptions: the Interrupt Descriptor Table (IDT)

+ Overview. Projects: Developing an OS Kernel for x86. ! Handling Intel Processor Exceptions: the Interrupt Descriptor Table (IDT) + Projects: Developing an OS Kernel for x86 Low-Level x86 Programming: Exceptions, Interrupts, and Timers + Overview! Handling Intel Processor Exceptions: the Interrupt Descriptor Table (IDT)! Handling

More information

Section 4: Threads CS162. September 15, Warmup Hello World Vocabulary 2

Section 4: Threads CS162. September 15, Warmup Hello World Vocabulary 2 CS162 September 15, 2016 Contents 1 Warmup 2 1.1 Hello World............................................ 2 2 Vocabulary 2 3 Problems 3 3.1 Join................................................ 3 3.2 Stack

More information

Hardware and Software Architecture. Chapter 2

Hardware and Software Architecture. Chapter 2 Hardware and Software Architecture Chapter 2 1 Basic Components The x86 processor communicates with main memory and I/O devices via buses Data bus for transferring data Address bus for the address of a

More information

Low Level Programming Lecture 2. International Faculty of Engineerig, Technical University of Łódź

Low Level Programming Lecture 2. International Faculty of Engineerig, Technical University of Łódź Low Level Programming Lecture 2 Intel processors' architecture reminder Fig. 1. IA32 Registers IA general purpose registers EAX- accumulator, usually used to store results of integer arithmetical or binary

More information

X86 Stack Calling Function POV

X86 Stack Calling Function POV X86 Stack Calling Function POV Computer Systems Section 3.7 Stack Frame Reg Value ebp xffff FFF0 esp xffff FFE0 eax x0000 000E Memory Address Value xffff FFF8 xffff FFF4 x0000 0004 xffff FFF4 x0000 0003

More information

Assembly Language. Lecture 2 x86 Processor Architecture

Assembly Language. Lecture 2 x86 Processor Architecture Assembly Language Lecture 2 x86 Processor Architecture Ahmed Sallam Slides based on original lecture slides by Dr. Mahmoud Elgayyar Introduction to the course Outcomes of Lecture 1 Always check the course

More information

Pre-virtualization internals

Pre-virtualization internals Pre-virtualization internals Joshua LeVasseur 3 March 2006 L4Ka.org Universität Karlsruhe (TH) Compile time overview Compiler C code Assembler code OS source code Hand-written assembler Afterburner Assembler

More information

Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998

Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998 Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998 Assembler Syntax Everything looks like this: label: instruction dest,src instruction label Comments: comment $ This is a comment

More information

3. Process Management in xv6

3. Process Management in xv6 Lecture Notes for CS347: Operating Systems Mythili Vutukuru, Department of Computer Science and Engineering, IIT Bombay 3. Process Management in xv6 We begin understanding xv6 process management by looking

More information

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86 Lecture 15 Intel Manual, Vol. 1, Chapter 3 Hampden-Sydney College Fri, Mar 6, 2009 Outline 1 2 Overview See the reference IA-32 Intel Software Developer s Manual Volume 1: Basic, Chapter 3. Instructions

More information

Complex Instruction Set Computer (CISC)

Complex Instruction Set Computer (CISC) Introduction ti to IA-32 IA-32 Processors Evolutionary design Starting in 1978 with 886 Added more features as time goes on Still support old features, although obsolete Totally dominate computer market

More information

Buffer Overflow Attack

Buffer Overflow Attack Buffer Overflow Attack What every applicant for the hacker should know about the foundation of buffer overflow attacks By (Dalgona@wowhacker.org) Email: zinwon@gmail.com 2005 9 5 Abstract Buffer overflow.

More information

Ausgewählte Betriebssysteme. Anatomy of a system call

Ausgewählte Betriebssysteme. Anatomy of a system call Ausgewählte Betriebssysteme Anatomy of a system call 1 User view #include int main(void) { printf( Hello World!\n ); return 0; } 2 3 Syscall (1) User: write(fd, buffer, sizeof(buffer)); size

More information

Section 4: Threads and Context Switching

Section 4: Threads and Context Switching CS162 September 19-20, 2017 Contents 1 Warmup 2 1.1 Hello World............................................ 2 2 Vocabulary 2 3 Problems 3 3.1 Join................................................ 3 3.2

More information

IA-32 Architecture COE 205. Computer Organization and Assembly Language. Computer Engineering Department

IA-32 Architecture COE 205. Computer Organization and Assembly Language. Computer Engineering Department IA-32 Architecture COE 205 Computer Organization and Assembly Language Computer Engineering Department King Fahd University of Petroleum and Minerals Presentation Outline Basic Computer Organization Intel

More information

IA32/Linux Virtual Memory Architecture

IA32/Linux Virtual Memory Architecture IA32/Linux Virtual Memory Architecture Basic Execution Environment Application Programming Registers General-purpose registers 31 0 EAX AH AL EBX BH BL ECX CH CL EDX DH DL EBP ESI EDI BP SI DI Segment

More information

The Instruction Set. Chapter 5

The Instruction Set. Chapter 5 The Instruction Set Architecture Level(ISA) Chapter 5 1 ISA Level The ISA level l is the interface between the compilers and the hardware. (ISA level code is what a compiler outputs) 2 Memory Models An

More information

Operating Systems and Protection CS 217

Operating Systems and Protection CS 217 Operating Systems and Protection CS 7 Goals of Today s Lecture How multiple programs can run at once o es o Context switching o control block o Virtual Boundary between parts of the system o User programs

More information

x86 assembly CS449 Fall 2017

x86 assembly CS449 Fall 2017 x86 assembly CS449 Fall 2017 x86 is a CISC CISC (Complex Instruction Set Computer) e.g. x86 Hundreds of (complex) instructions Only a handful of registers RISC (Reduced Instruction Set Computer) e.g. MIPS

More information

Protection and System Calls. Otto J. Anshus

Protection and System Calls. Otto J. Anshus Protection and System Calls Otto J. Anshus Protection Issues CPU protection Prevent a user from using the CPU for too long Throughput of jobs, and response time to events (incl. user interactive response

More information

MICROPROCESSOR TECHNOLOGY

MICROPROCESSOR TECHNOLOGY MICROPROCESSOR TECHNOLOGY Assis. Prof. Hossam El-Din Moustafa Lecture 5 Ch.2 A Top-Level View of Computer Function (Cont.) 24-Feb-15 1 CPU (CISC & RISC) Intel CISC, Motorola RISC CISC (Complex Instruction

More information

x86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT

x86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT x86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT kaashoek@mit.edu Outline Enforcing modularity with virtualization Virtualize processor and memory x86 mechanism for virtualization

More information

Introduction to IA-32. Jo, Heeseung

Introduction to IA-32. Jo, Heeseung Introduction to IA-32 Jo, Heeseung IA-32 Processors Evolutionary design Starting in 1978 with 8086 Added more features as time goes on Still support old features, although obsolete Totally dominate computer

More information

CSE 153 Design of Operating Systems

CSE 153 Design of Operating Systems CSE 153 Design of Operating Systems Winter 19 Lecture 3: OS model and Architectural Support Last time/today Historic evolution of Operating Systems (and computing!) Today: We start our journey in exploring

More information

For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to

For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Author...xi

More information

INTRODUCTION TO IA-32. Jo, Heeseung

INTRODUCTION TO IA-32. Jo, Heeseung INTRODUCTION TO IA-32 Jo, Heeseung IA-32 PROCESSORS Evolutionary design Starting in 1978 with 8086 Added more features as time goes on Still support old features, although obsolete Totally dominate computer

More information

6.828: Using Virtual Memory. Adam Belay

6.828: Using Virtual Memory. Adam Belay 6.828: Using Virtual Memory Adam Belay abelay@mit.edu 1 Outline Cool things you can do with virtual memory: Lazy page allocation (homework) Better performance/efficiency E.g. One zero-filled page E.g.

More information

The x86 Architecture

The x86 Architecture The x86 Architecture Lecture 24 Intel Manual, Vol. 1, Chapter 3 Robb T. Koether Hampden-Sydney College Fri, Mar 20, 2015 Robb T. Koether (Hampden-Sydney College) The x86 Architecture Fri, Mar 20, 2015

More information

Machine Programming 3: Procedures

Machine Programming 3: Procedures Machine Programming 3: Procedures CS61, Lecture 5 Prof. Stephen Chong September 15, 2011 Announcements Assignment 2 (Binary bomb) due next week If you haven t yet please create a VM to make sure the infrastructure

More information

CS533 Concepts of Operating Systems. Jonathan Walpole

CS533 Concepts of Operating Systems. Jonathan Walpole CS533 Concepts of Operating Systems Jonathan Walpole Improving IPC by Kernel Design & The Performance of Micro- Kernel Based Systems The IPC Dilemma IPC is very import in µ-kernel design - Increases modularity,

More information

x86 assembly CS449 Spring 2016

x86 assembly CS449 Spring 2016 x86 assembly CS449 Spring 2016 CISC vs. RISC CISC [Complex instruction set Computing] - larger, more feature-rich instruction set (more operations, addressing modes, etc.). slower clock speeds. fewer general

More information

x86 Assembly Tutorial COS 318: Fall 2017

x86 Assembly Tutorial COS 318: Fall 2017 x86 Assembly Tutorial COS 318: Fall 2017 Project 1 Schedule Design Review: Monday 9/25 Sign up for 10-min slot from 3:00pm to 7:00pm Complete set up and answer posted questions (Official) Precept: Monday

More information

Procedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27

Procedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27 Procedure Calls Young W. Lim 2016-11-05 Sat Young W. Lim Procedure Calls 2016-11-05 Sat 1 / 27 Outline 1 Introduction References Stack Background Transferring Control Register Usage Conventions Procedure

More information

Assembler Programming. Lecture 2

Assembler Programming. Lecture 2 Assembler Programming Lecture 2 Lecture 2 8086 family architecture. From 8086 to Pentium4. Registers, flags, memory organization. Logical, physical, effective address. Addressing modes. Processor Processor

More information

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit Slides prepared by Kip R. Irvine Revision date: 09/25/2002

More information

CS241 Computer Organization Spring 2015 IA

CS241 Computer Organization Spring 2015 IA CS241 Computer Organization Spring 2015 IA-32 2-10 2015 Outline! Review HW#3 and Quiz#1! More on Assembly (IA32) move instruction (mov) memory address computation arithmetic & logic instructions (add,

More information

CS 318 Principles of Operating Systems

CS 318 Principles of Operating Systems CS 318 Principles of Operating Systems Fall 2018 Lecture 5: Thread Ryan Huang Slides adapted from Geoff Voelker s and David Mazières lectures Administrivia Lab 0 grading in progress Lab 1 review session

More information

CS 318 Principles of Operating Systems

CS 318 Principles of Operating Systems CS 318 Principles of Operating Systems Fall 2017 Lecture 5: Thread Ryan Huang Administrivia HW1 solution released on Piazza resources Lab 0 grading - In progress - Cheating policy Lab 1 review session

More information

Memory Models. Registers

Memory Models. Registers Memory Models Most machines have a single linear address space at the ISA level, extending from address 0 up to some maximum, often 2 32 1 bytes or 2 64 1 bytes. Some machines have separate address spaces

More information

Procedure Calls. Young W. Lim Mon. Young W. Lim Procedure Calls Mon 1 / 29

Procedure Calls. Young W. Lim Mon. Young W. Lim Procedure Calls Mon 1 / 29 Procedure Calls Young W. Lim 2017-08-21 Mon Young W. Lim Procedure Calls 2017-08-21 Mon 1 / 29 Outline 1 Introduction Based on Stack Background Transferring Control Register Usage Conventions Procedure

More information

System Calls. A contract between processes and the operating system. Michael E. Locasto. Department of Computer Science UofC CPSC 457

System Calls. A contract between processes and the operating system. Michael E. Locasto. Department of Computer Science UofC CPSC 457 System Calls A contract between processes and the operating system Michael E. Locasto Department of Computer Science UofC CPSC 457 September 24, 2014 Agenda Learning Objective (1 minute) understand the

More information

143A: Principles of Operating Systems. Lecture 5: Address translation. Anton Burtsev October, 2018

143A: Principles of Operating Systems. Lecture 5: Address translation. Anton Burtsev October, 2018 143A: Principles of Operating Systems Lecture 5: Address translation Anton Burtsev October, 2018 Two programs one memory Or more like renting a set of rooms in an office building Or more like renting a

More information

Binghamton University. CS-220 Spring X86 Debug. Computer Systems Section 3.11

Binghamton University. CS-220 Spring X86 Debug. Computer Systems Section 3.11 X86 Debug Computer Systems Section 3.11 GDB is a Source Level debugger We have learned how to debug at the C level Now, C has been translated to X86 assembler! How does GDB play the shell game? Makes it

More information

CMSC 313 Lecture 12. Project 3 Questions. How C functions pass parameters. UMBC, CMSC313, Richard Chang

CMSC 313 Lecture 12. Project 3 Questions. How C functions pass parameters. UMBC, CMSC313, Richard Chang Project 3 Questions CMSC 313 Lecture 12 How C functions pass parameters UMBC, CMSC313, Richard Chang Last Time Stack Instructions: PUSH, POP PUSH adds an item to the top of the stack POP

More information

Microprocessors ( ) Fall 2010/2011 Lecture Notes # 15. Stack Operations. 10 top

Microprocessors ( ) Fall 2010/2011 Lecture Notes # 15. Stack Operations. 10 top Microprocessors (0630371) Fall 2010/2011 Lecture Notes # 15 Stack Operations Objectives of the Lecture Runtime Stack PUSH Operation POP Operation Initializing the Stack PUSH and POP Instructions Stack

More information

ECE 391 Exam 1 Review Session - Spring Brought to you by HKN

ECE 391 Exam 1 Review Session - Spring Brought to you by HKN ECE 391 Exam 1 Review Session - Spring 2018 Brought to you by HKN DISCLAIMER There is A LOT (like a LOT) of information that can be tested for on the exam, and by the nature of the course you never really

More information

Processes (Intro) Yannis Smaragdakis, U. Athens

Processes (Intro) Yannis Smaragdakis, U. Athens Processes (Intro) Yannis Smaragdakis, U. Athens Process: CPU Virtualization Process = Program, instantiated has memory, code, current state What kind of memory do we have? registers + address space Let's

More information

x86 architecture et similia

x86 architecture et similia x86 architecture et similia 1 FREELY INSPIRED FROM CLASS 6.828, MIT A full PC has: PC architecture 2 an x86 CPU with registers, execution unit, and memory management CPU chip pins include address and data

More information

Introduction to the Process David E. Culler CS162 Operating Systems and Systems Programming Lecture 2 Sept 3, 2014

Introduction to the Process David E. Culler CS162 Operating Systems and Systems Programming Lecture 2 Sept 3, 2014 Introduction to the Process David E. Culler CS162 Operating Systems and Systems Programming Lecture 2 Sept 3, 2014 Reading: A&D CH2.1-7 HW: 0 out, due 9/8 Recall: What is an operating system? Special layer

More information

238P: Operating Systems. Lecture 5: Address translation. Anton Burtsev January, 2018

238P: Operating Systems. Lecture 5: Address translation. Anton Burtsev January, 2018 238P: Operating Systems Lecture 5: Address translation Anton Burtsev January, 2018 Two programs one memory Very much like car sharing What are we aiming for? Illusion of a private address space Identical

More information

COS 318: Operating Systems

COS 318: Operating Systems COS 318: Operating Systems OS Structures and System Calls Prof. Margaret Martonosi Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall11/cos318/ Outline Protection

More information

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14 SYSTEM CALL IMPLEMENTATION CS124 Operating Systems Fall 2017-2018, Lecture 14 2 User Processes and System Calls Previously stated that user applications interact with the kernel via system calls Typically

More information

Instruction Set Architectures

Instruction Set Architectures Instruction Set Architectures ISAs Brief history of processors and architectures C, assembly, machine code Assembly basics: registers, operands, move instructions 1 What should the HW/SW interface contain?

More information

Microkernel Design A walk through selected aspects of

Microkernel Design A walk through selected aspects of Microkernel Design A walk through selected aspects of kernel design and sel4 These slides are made distributed under the Creative Commons Attribution 3.0 License, unless otherwise noted on individual slides.

More information

Assembly Language Programming 64-bit environments

Assembly Language Programming 64-bit environments Assembly Language Programming 64-bit environments October 17, 2017 Some recent history Intel together with HP start to work on 64-bit processor using VLIW technology. Itanium processor is born with the

More information

What You Need to Know for Project Three. Dave Eckhardt Steve Muckle

What You Need to Know for Project Three. Dave Eckhardt Steve Muckle What You Need to Know for Project Three Dave Eckhardt Steve Muckle Overview Introduction to the Kernel Project Mundane Details in x86 registers, paging, the life of a memory access, context switching,

More information

System calls and assembler

System calls and assembler System calls and assembler Michal Sojka sojkam1@fel.cvut.cz ČVUT, FEL License: CC-BY-SA 4.0 System calls (repetition from lectures) A way for normal applications to invoke operating system (OS) kernel's

More information

143A: Principles of Operating Systems. Lecture 6: Address translation. Anton Burtsev January, 2017

143A: Principles of Operating Systems. Lecture 6: Address translation. Anton Burtsev January, 2017 143A: Principles of Operating Systems Lecture 6: Address translation Anton Burtsev January, 2017 Address translation Segmentation Descriptor table Descriptor table Base address 0 4 GB Limit

More information

W4118: virtual machines

W4118: virtual machines W4118: virtual machines Instructor: Junfeng Yang References: Modern Operating Systems (3 rd edition), Operating Systems Concepts (8 th edition), previous W4118, and OS at MIT, Stanford, and UWisc Virtual

More information

Lecture 4 CIS 341: COMPILERS

Lecture 4 CIS 341: COMPILERS Lecture 4 CIS 341: COMPILERS CIS 341 Announcements HW2: X86lite Available on the course web pages. Due: Weds. Feb. 7 th at midnight Pair-programming project Zdancewic CIS 341: Compilers 2 X86 Schematic

More information

Basic Execution Environment

Basic Execution Environment Basic Execution Environment 3 CHAPTER 3 BASIC EXECUTION ENVIRONMENT This chapter describes the basic execution environment of an Intel Architecture processor as seen by assembly-language programmers.

More information

x86 Assembly Crash Course Don Porter

x86 Assembly Crash Course Don Porter x86 Assembly Crash Course Don Porter Registers ò Only variables available in assembly ò General Purpose Registers: ò EAX, EBX, ECX, EDX (32 bit) ò Can be addressed by 8 and 16 bit subsets AL AH AX EAX

More information

Systems Architecture I

Systems Architecture I Systems Architecture I Topics Assemblers, Linkers, and Loaders * Alternative Instruction Sets ** *This lecture was derived from material in the text (sec. 3.8-3.9). **This lecture was derived from material

More information

COS 318: Operating Systems

COS 318: Operating Systems COS 318: Operating Systems OS Structures and System Calls Jaswinder Pal Singh Computer Science Department Princeton University (http://www.cs.princeton.edu/courses/cos318/) Outline Protection mechanisms

More information

AMD-K5. Software Development Guide PROCESSOR

AMD-K5. Software Development Guide PROCESSOR AMD-K5 TM PROCESSOR Software Development Guide Publication # 20007 Rev: D Amendment/0 Issue Date: September 1996 This document contains information on a product under development at Advanced Micro Devices

More information

Computer Organization (II) IA-32 Processor Architecture. Pu-Jen Cheng

Computer Organization (II) IA-32 Processor Architecture. Pu-Jen Cheng Computer Organization & Assembly Languages Computer Organization (II) IA-32 Processor Architecture Pu-Jen Cheng Materials Some materials used in this course are adapted from The slides prepared by Kip

More information

Operating systems offer processes running in User Mode a set of interfaces to interact with hardware devices such as

Operating systems offer processes running in User Mode a set of interfaces to interact with hardware devices such as System call Overview 2 Operating systems offer processes running in User Mode a set of interfaces to interact with hardware devices such as the CPU disks printers Unix systems implement most interfaces

More information

Information Security II Prof. Kamakoti Department of Computer Science and Engineering Indian Institute of Technology, Madras

Information Security II Prof. Kamakoti Department of Computer Science and Engineering Indian Institute of Technology, Madras Information Security II Prof. Kamakoti Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 30 Task Switch recap - Week 6 (Refer Slide Time: 00:09) So welcome back

More information

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-11: 80x86 Architecture

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-11: 80x86 Architecture ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-11: 80x86 Architecture 1 The 80x86 architecture processors popular since its application in IBM PC (personal computer). 2 First Four generations

More information

MICROPROCESSOR MICROPROCESSOR ARCHITECTURE. Prof. P. C. Patil UOP S.E.COMP (SEM-II)

MICROPROCESSOR MICROPROCESSOR ARCHITECTURE. Prof. P. C. Patil UOP S.E.COMP (SEM-II) MICROPROCESSOR UOP S.E.COMP (SEM-II) 80386 MICROPROCESSOR ARCHITECTURE Prof. P. C. Patil Department of Computer Engg Sandip Institute of Engineering & Management Nashik pc.patil@siem.org.in 1 Introduction

More information

COS 318: Operating Systems. Overview. Prof. Margaret Martonosi Computer Science Department Princeton University

COS 318: Operating Systems. Overview. Prof. Margaret Martonosi Computer Science Department Princeton University COS 318: Operating Systems Overview Prof. Margaret Martonosi Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall11/cos318/ Announcements Precepts: Tue (Tonight)!

More information

The Microprocessor and its Architecture

The Microprocessor and its Architecture The Microprocessor and its Architecture Contents Internal architecture of the Microprocessor: The programmer s model, i.e. The registers model The processor model (organization) Real mode memory addressing

More information

Advanced Computer Architecture

Advanced Computer Architecture ECE 563 Advanced Computer Architecture Fall 2007 Lecture 14: Virtual Machines 563 L14.1 Fall 2009 Outline Types of Virtual Machine User-level (or Process VMs) System-level Techniques for implementing all

More information

Homework / Exam. Return and Review Exam #1 Reading. Machine Projects. Labs. S&S Extracts , PIC Data Sheet. Start on mp3 (Due Class 19)

Homework / Exam. Return and Review Exam #1 Reading. Machine Projects. Labs. S&S Extracts , PIC Data Sheet. Start on mp3 (Due Class 19) Homework / Exam Return and Review Exam #1 Reading S&S Extracts 385-393, PIC Data Sheet Machine Projects Start on mp3 (Due Class 19) Labs Continue in labs with your assigned section 1 Interrupts An interrupt

More information