Boot Procedure. BP (boot processor) Start BIOS Firmware Load A2 Bootfile Initialize modules Module Machine Module Heaps

Size: px
Start display at page:

Download "Boot Procedure. BP (boot processor) Start BIOS Firmware Load A2 Bootfile Initialize modules Module Machine Module Heaps"

Transcription

1 Boot rocedure Start BIOS Firmware Load A2 Bootfile Initialize modules Module Machine Module Heaps Module Objects Setup scheduler and self process Module Kernel Start all processors Module Bootconsole read configuration and execute boot commands B (boot processor) 206

2 rocessor Startup Start processor (Bootprocessor) 1. Setup boot program 2. Enter processor IDs into table 3. Send startup message to via AIC 4. Wait with timeout on started flag by Boot program (For each processor) 1. Set 32-bit runtime environment for all processors 2. Initialize control registers, memory management, interrupt handling, AIC 3. Set started flag Machine.StartM 4. Setup Scheduler 5. Bootprocessor proceeds with boot console Machine.Initrocessors, Machine.InitBootage Machine.arseMConfig Machine.Startrocessor Machine.EnterM Objects.Start 207

3 2.3. ACTIVITY MANAGEMENT 208

4 Life Cycle of Activities Running Awaiting Condition Awaiting Lock NIL Ready Terminated 209

5 Runtime Data Structures running array processor id object header object header object header NIL NIL cond lock cond lock cond lock ready queues array interrupt array NIL NIL NIL idle low medium high GC RT priority NIL NIL NIL NIL 4 5 irq no. 210

6 rocess Descriptors TYE rocess = OBJECT stack: Stack; state: rocessstate; preempted: BOOLEAN; condition: Condition; conditionf: ADDRESS; priority: INTEGER; obj: OBJECT; next: rocess END rocess; rocessqueue = RECORD head, tail: rocess END; VAR ready: ARRAY Numriorities OF rocessqueue; running: ARRAY Numrocessors OF rocess; 211

7 rocess Dispatching ROCEDURE Enter (p: rocess); BEGIN ut(ready[p.priority], p); IF p.priority > maxready THEN maxready := p.priority END END Enter; NIL NIL NIL ROCEDURE Select (VAR new: rocess; priority: integer); BEGIN LOO IF maxready < priority THEN new := nil; EXIT END; Get(ready[maxReady], new); IF(new # NIL) OR (maxready = Minriority) THEN EXIT END; maxready := maxready-1 END END Select; NIL NIL NIL 212

8 rocess Creation ROCEDURE Createrocess (body: ADDRESS; priority: INTEGER; obj: OBJECT); VAR p: rocess; BEGIN NEW(p); NewStack(p, body, obj); p.preempted := false; p.obj := obj; p.next := nil; RegisterFinalizer(p, Finalizerocess); Acquire(Objects); (* module lock *) IF priority # 0 THEN p.priority := priority ELSE (* inherit priority of creator *) p.priority := running[rocessorid()].priority END; Enter(p); Release(Objects) END Createrocess; NIL Awaiting Condition Running Ready Awaiting Lock Terminated 213

9 Stack Management Use virtual adressing Allocate stack in page units Use page fault for detecting stack overflow Deallocate stack via garbage collector (in process finalizer) Createrocess age fault Finalize Allocate first frame Allocate another frame Deallocate all frames 214

10 Memory Layout 4GB 3.75 GB Mappings Stacks 3GB Devices VIRTUAL REAL 32MB Heap age Heap 1MB 640KB 4KB 0KB Devices age Heap Unmapped Heap Devices age Heap age Heap System RAM 215

11 Stack Allocation Stack Stack Stack unmapped unmapped unmapped unmapped unmapped initially after extension 216

12 Context Switch Synchronous Explicit Terminate Yield Implicit Awaiting condition Mutual exclusion Asynchronous reemption riority handling Timeslicing 217

13 Synchronous Context Switch (1) ROCEDURE SwitchTo (VAR running: rocess; new: rocess); Call SwitchTo stack bottom Stack Return procedure activation frame fp sp running new retpc dlink stack top 218

14 Synchronous Context Switch (2) cur F Reduced process state new F running new retpc dlink fp sp (fp, sp) (fp, sp) fp sp running new retpc dlink 219

15 Asynchronous Context Switch cur Full process state new fp (fp, sp) (fp, sp) sp Registers saved by interrupt fp sp 220

16 Stack Layout after Interrupt 72.GS 68.FS 64.DS 60.ES ; or haltcode 56.SS 52.ES ; or haltcode 48.EFLAGS 44.CS 40.EI 36.EB ERR ; pushed by processor or glue code, popped by O EB 32.ES0 INT ; pushed by glue code, popped by O EB 28.EAX 24.ECX 20.EDX 16.EBX 12.ES0 08.EB/ERR ; exchanged by glue code 04.ESI 00.EDI state: State via interrupt/ IRETD via Glue Code via USHAD/ OAD 221

17 First Level Interrupt Glue Code USH 0 (depending on interrupt number) XCHG [ES], EB USH IRQnumber JUM FieldIRQ (or FieldInterrupt, depending on interrupt number) 222

18 First Level Interrupt Code (1) ROCEDURE Interrupt; CODE {SYSTEM.i386} ; called by interrupt handler (= glue code) USHAD ; save all registers (EB = error code) LEA EB, [ES+36] ; procedure link MOV EBX, [ES+32] ; EBX = int number LEA EAX, inthandler MOV EAX, [EAX][EBX*4] ; now call all handlers for this interrupt OAD ; now EB = error code O EB ; now EB = INT O EB ; now EB = caller EB IRETD END Interrupt; inthandler int number first first first object handler next handler object next 223

19 Switch Code (1) ROCEDURE Switch (VAR cur: rocess; new: rocess); BEGIN cur.state.s := SYSTEM.GETREG(S); cur.state.f := SYSTEM.GETREG(F); cur := new; IF ~cur.preempted then (* return from call *) SYSTEM.UTREG(S, cur.state.s); SYSTEM.UTREG(F, cur.state.f) Release(Objects); ELSE (* return from interrupt *) cur.preempted := FALSE; SYSTEM.UTREG(S, cur.state.s); ushstate(cur.state.eflags, cur.state.cs, cur.state.ei, cur.state.eax, cur.state.ecx, cur.state.edx, cur.state.ebx, 0, cur.state.eb, cur.state.esi, cur.state.edi ); Release(Objects); JumpState END END Switch; synchronous synchronous/ asynchronous 224

20 Switch Code (2) ROCEDURE -ushstate(eflags: SET; CS, EI, EAX, ECX, EDX, EBX, ES, EB, ESI, EDI: LONGINT); CODE {SYSTEM.i386} (* to omit call protocol *) END ushstate; ROCEDURE -JumpState; CODE {SYSTEM.i386} OAD IRETD END opstate; 225

21 Example 1: Termination ROCEDURE Terminate; VAR new: rocess; BEGIN Acquire(Objects); Select(new, Minriority); Switch(running[rocessorID()], new) END Terminate; NIL Awaiting Condition Running Ready Awaiting Lock Terminated 226

22 Example 2: Yield ROCEDURE Yield; VAR id: INTEGER; new: rocess; BEGIN Acquire(Objects); id := rocessorid(); Select(new, running[id].priority); IF new # NIL THEN Enter(running[id]); Switch(running[id], new) ELSE Release(Objects) END END Yield; NIL Awaiting Condition Running Ready Awaiting Lock Terminated 227

23 Idle Activity in Objects Idle = OBJECT BEGIN{ ACTIVE, SAFE, RIORITY(rioIdle)} LOO REEAT Machine.SpinHint UNTIL maxready > Minriority; Yield END END Idle; 228

24 Example: Timeslicing ROCEDURE Timeslice (VAR state: rocessorstate); VAR id: integer; new: rocess; BEGIN Acquire(Objects); id := rocessorid(); IF running[id].priority # Idle THEN Select(new, running[id].priority); IF new # NIL THEN running[id].preempted := true; CopyState(state, running[id].state); Enter(running[id]); running[id] := new; IF new.preempted then new.preempted := false; CopyState(new.state, state) ELSE SwitchToState(new, state) END END END; Release(Objects) END Timeslice; return from interrupt of new process simulate return from procedure switch NIL asynchronous Awaiting Condition Running Ready Awaiting Lock synchronous/ asynchronous Terminated 229

25 Context Switching Scenarios from (synchronous suspended) Exchange fp, sp to (synchronous suspended) from (running) Call Switch Interrupt copy state copy state Return from Switch Return from interrupt to (running) from (asynchronous suspended) Exchange fp, sp to (asynchronous suspended) 230

26 Synchronization Object locking Condition management 231

27 Object Descriptors ObjectHeader = RECORD headerlock: BOOLEAN; lockedby: rocess; awaitinglock: rocessqueue; awaitingcondition: rocessqueue; Fields added by system to objects with mutual exclusion Type-specific instance fields END; 232

28 Object Locking ROCEDURE Lock (obj: object); VAR r, new: rocess; BEGIN r := running[rocessorid()]; AcquireObject(obj.hdr.headerLock); IF obj.hdr.lockedby = nil THEN obj.hdr.lockedby := r; ReleaseObject(obj.hdr.headerLock); ELSE Acquire(Objects); ut(obj.hdr.awaitinglock, r); ReleaseObject(obj.hdr.headerLock); Select(new, Minriority); SwitchTo(running[rocessorID()], new) END END Lock; NIL Awaiting Condition Running Ready Awaiting Lock Terminated 233

29 Object Unlocking ROCEDURE Unlock (obj: object); Running VAR c: rocess; BEGIN Awaiting Condition Awaiting Lock c := FindCondition(obj.hdr.awaitingCondition) AcquireObject(obj.hdr.headerLock); NIL Ready Terminated IF c = NIL THEN END; Get(obj.hdr.awaitingLock, c); Atomic Lock Transfer Eggshell-Model! obj.hdr.lockedby := c ReleaseObject(obj.hdr.headerLock); IF c # NIL THEN Acquire(Objects); Enter(c); Release(Objects) END; END Unlock; 234

30 Condition Management Condition Type TYE Condition = ROCEDURE(fp: ADDRESS): BOOLEAN; Condition Boxing ROEDURE $Condition(fp: ADDRESS): BOOLEAN; BEGIN RETURN condition from await statement END $Condition; Await Code IF ~$Condition(F) THEN Await($Condition, F, SELF) END 235

31 AWAIT Code ROCEDURE Await (condition: Condition; fp: address; obj: object); VAR r, t, new: rocess; BEGIN AcquireObject(obj.hdr.headerLock); c := FindCondition(obj.hdr.awaitingCondition); IF c = NIL THEN Get(obj.hdr.awaitingLock, c); END; obj.hdr.lockedby := c Acquire(Objects); IF c # NIL THEN Enter(c) END; r := running[rocessorid()]; r.condition := condition; r.conditionf := fp; ut(obj.hdr.awaitingcondition, r); ReleaseObject(obj.hdr.headerLock); Select(new, Minriority); SwitchTo(running[rocessorID()], new) END Await; NIL Awaiting Condition Running Ready Awaiting Lock Terminated 236

32 Condition Evaluation ROCEDURE FindCondition (VAR q: rocessqueue): rocess; VAR first, c: rocess; BEGIN Get(q, first); IF first.condition(first.conditionf) THEN RETURN f END; ut(q, first); WHILE q.head # first DO Get(q, c); IF c.condition(c.conditionf) THEN RETURN c END; ut(q, c) END; RETURN NIL END FindCondition; 237

33 riority Inversion Inversion caused by an immediately shared resource High 2 t Med 3 t Low 1 t Ressource R (Object) 238

34 riority Inheritance High t Med 3 t Low 1 1 t Ressource R (Object) 239

35 riority Inversion Inversion caused by not immediately shared resource High 3 Medium 1 1 Low 2 Ressource X Ressource Y Ressource Z 240

36 riority Inheritance High Medium 1 1 Low 2 2 Ressource X Ressource Y Ressource Z 241

37 Invariants 1 Waits on R1 Is owned by A process waits on a resource if and only if the resource is onwed by a different process 2 5 R3 3 R2 4 I2. A resource is locked by at most one process I1. A process waits on at most one resource 242

38 ossible Transitions process acquires and receives free resource R1 1 waiting processes can neither acquire nor release resources 2 R1 1 rocess tries to acquire locked resource 2 R1 1 R2 process releases resource R1 1 R2 2 R1 waiting process receives resource 2 R1 1 R2 2 R1 243

39 Waitingriorities List (Re-)Setting the waitingon pointer R 2 1 array of number of waiting processes with indicated priority R 2 2 priority I3. Sum of digits equals overal number of waiting processes 244

40 LockedByriorities List (Re-)Setting the lockedby pointer R1 1 1 R R2 1 2 array of number of resources with indicated priority of highestpriority waiting process R2 1 2 I4. Sum of digits equals overal number of owned resources 245

41 Further Rules / Invariants A process that releases a resource does not simultaneously wait on a resource. I5. For each resource, the number of waiting processes and their priorities are available at all times. invariant held during (re-)setting the waitingon pointer I6. For each process, the highest priority of indirectly waiting processes is known at all times invariant held during (re-) setting the lockedby pointer 246

42 Handling riority Inversion (Setting WaitingOn ) R R R R

43 Handling riority Inversion (Resetting LockedBy ) 2 R R

44 Handling riority Inversion Resetting LockedBy : how to preserve initial priorities? 2 R R 1 1?

45 Handling riority Inversion Resource and rocess Initialization Resource is allocated with virtual idle process rocess is allocated with virtual resource of process initial priority R R

2.3. ACTIVITY MANAGEMENT

2.3. ACTIVITY MANAGEMENT 2.3. ACTIVITY MANAGEMENT 204 Life Cycle of Activities Running Awaiting Condition Awaiting Lock NIL Ready Terminated 205 Runtime Data Structures running array global 1 2 3 4 processor id object header object

More information

2.3. ACTIVITY MANAGEMENT

2.3. ACTIVITY MANAGEMENT 2.3. ACTIVITY MANAGEMENT 211 Life Cycle of Activities Running Awaiting Condition Awaiting Lock NIL Ready Terminated 212 Runtime Data Structures running array P P P P 1 2 3 4 processor id object header

More information

CASE STUDY 2. A2 166

CASE STUDY 2. A2 166 CASE STUDY 2. A2 166 Architecture Shared Memory Bus P0 P1 P2 P3 Symmetrical Multiple Processors (SMP) 167 Useful Resources (x86 compatible HW) osdev.org: http://wiki.osdev.org SDM: Intel 64 and IA-32 Architectures

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

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

µ-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

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

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

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

Hazard Pointers. Number of threads unbounded time to check hazard pointers also unbounded! difficult dynamic bookkeeping! thread B - hp1 - hp2

Hazard Pointers. Number of threads unbounded time to check hazard pointers also unbounded! difficult dynamic bookkeeping! thread B - hp1 - hp2 Hazard Pointers Store pointers of memory references about to be accessed by a thread Memory allocation checks all hazard pointers to avoid the ABA problem thread A - hp1 - hp2 thread B - hp1 - hp2 thread

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

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

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

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

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

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

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

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

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

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

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

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

CASE STUDY 2. A2 169

CASE STUDY 2. A2 169 CASE STUDY 2. A2 169 Architecture Shared Memory Bus P0 P1 P2 P3 Symmetrical Multiple Processors (SMP) 170 Useful Resources (x86 compatible HW) osdev.org: http://wiki.osdev.org SDM: Intel 64 and IA-32 Architectures

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

Digital Forensics Lecture 3 - Reverse Engineering

Digital Forensics Lecture 3 - Reverse Engineering Digital Forensics Lecture 3 - Reverse Engineering Low-Level Software Akbar S. Namin Texas Tech University Spring 2017 Reverse Engineering High-Level Software Low-level aspects of software are often the

More information

CMSC 412 Project #3 Threads & Synchronization Due March 17 th, 2017, at 5:00pm

CMSC 412 Project #3 Threads & Synchronization Due March 17 th, 2017, at 5:00pm CMSC 412 Project #3 Threads & Synchronization Due March 17 th, 2017, at 5:00pm Overview User level threads. You will implement user level threads where each thread has it s own stack, but shares the program,

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

Final Examination. Thursday, December 3, :20PM 620 PM. NAME: Solutions to Selected Problems ID:

Final Examination. Thursday, December 3, :20PM 620 PM. NAME: Solutions to Selected Problems ID: CSE 237B EMBEDDED SOFTWARE, FALL 2009 PROF. RAJESH GUPTA Final Examination Thursday, December 3, 2009 5:20PM 620 PM NAME: Solutions to Selected Problems ID: Problem Max. Points Points 1 20 2 25 3 35 4

More information

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads Today s Topics COS 318: Operating Systems Implementing Threads u Thread implementation l Non-preemptive versus preemptive threads l Kernel vs. user threads Jaswinder Pal Singh and a Fabulous Course Staff

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

Processes and Tasks What comprises the state of a running program (a process or task)?

Processes and Tasks What comprises the state of a running program (a process or task)? Processes and Tasks What comprises the state of a running program (a process or task)? Microprocessor Address bus Control DRAM OS code and data special caches code/data cache EAXEBP EIP DS EBXESP EFlags

More information

Whatever can go wrong will go wrong. attributed to Edward A. Murphy. Murphy was an optimist. authors of lock-free programs LOCK FREE KERNEL

Whatever can go wrong will go wrong. attributed to Edward A. Murphy. Murphy was an optimist. authors of lock-free programs LOCK FREE KERNEL Whatever can go wrong will go wrong. attributed to Edward A. Murphy Murphy was an optimist. authors of lock-free programs LOCK FREE KERNEL 251 Literature Maurice Herlihy and Nir Shavit. The Art of Multiprocessor

More information

Process Description and Control. Chapter 3

Process Description and Control. Chapter 3 Process Description and Control 1 Chapter 3 2 Processes Working definition: An instance of a program Processes are among the most important abstractions in an OS all the running software on a computer,

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

Chapter 11. Addressing Modes

Chapter 11. Addressing Modes Chapter 11 Addressing Modes 1 2 Chapter 11 11 1 Register addressing mode is the most efficient addressing mode because the operands are in the processor itself (there is no need to access memory). Chapter

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

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

Chapter 2. lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1

Chapter 2. lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1 Chapter 2 1 MIPS Instructions Instruction Meaning add $s1,$s2,$s3 $s1 = $s2 + $s3 sub $s1,$s2,$s3 $s1 = $s2 $s3 addi $s1,$s2,4 $s1 = $s2 + 4 ori $s1,$s2,4 $s2 = $s2 4 lw $s1,100($s2) $s1 = Memory[$s2+100]

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

Review: Easy Piece 1

Review: Easy Piece 1 CS 537 Lecture 10 Threads Michael Swift 10/9/17 2004-2007 Ed Lazowska, Hank Levy, Andrea and Remzi Arpaci-Dussea, Michael Swift 1 Review: Easy Piece 1 Virtualization CPU Memory Context Switch Schedulers

More information

Programming Languages

Programming Languages TECHNISCHE UNIVERSITÄT MÜNCHEN FAKULTÄT FÜR INFORMATIK Programming Languages Concurrency: Atomic Executions, Locks and Monitors Dr. Michael Petter Winter term 2016 Atomic Executions, Locks and Monitors

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

Assembly Language for Intel-Based Computers, 4 th Edition. Kip R. Irvine. Chapter 2: IA-32 Processor Architecture

Assembly Language for Intel-Based Computers, 4 th Edition. Kip R. Irvine. Chapter 2: IA-32 Processor Architecture Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 2: IA-32 Processor Architecture Chapter Overview General Concepts IA-32 Processor Architecture IA-32 Memory Management Components

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

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

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

CS 537 Lecture 2 - Processes

CS 537 Lecture 2 - Processes CS 537 Lecture 2 - Processes Michael Swift 1 Basic Structure Kernel is a big program that starts when you boot your program Has full access to physical hardware. User programs, utilities, services see

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

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

6. Mechanism: Limited Direct Execution

6. Mechanism: Limited Direct Execution 6. Mechanism: Limited Direct Execution Oerating System: Three Easy Pieces AOS@UC 1 How to efficiently virtualize the CPU with control? The OS needs to share the hysical CPU by time sharing. Issue w Performance:

More information

Addressing Modes on the x86

Addressing Modes on the x86 Addressing Modes on the x86 register addressing mode mov ax, ax, mov ax, bx mov ax, cx mov ax, dx constant addressing mode mov ax, 25 mov bx, 195 mov cx, 2056 mov dx, 1000 accessing data in memory There

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

Compiler Construction

Compiler Construction Compiler Construction Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-16/cc/ Recap: Static Data Structures Outline of Lecture 18 Recap:

More information

Concurrent Programming using Threads

Concurrent Programming using Threads Concurrent Programming using Threads Threads are a control mechanism that enable you to write concurrent programs. You can think of a thread in an object-oriented language as a special kind of system object

More information

Compiler Design Spring 2017

Compiler Design Spring 2017 Compiler Design Spring 2017 6.0 Runtime system and object layout Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation 1 Runtime system Some open issues from last time Handling

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

An Introduction to x86 ASM

An Introduction to x86 ASM An Introduction to x86 ASM Malware Analysis Seminar Meeting 1 Cody Cutler, Anton Burtsev Registers General purpose EAX, EBX, ECX, EDX ESI, EDI (index registers, but used as general in 32-bit protected

More information

Overview. Constructors and destructors Virtual functions Single inheritance Multiple inheritance RTTI Templates Exceptions Operator Overloading

Overview. Constructors and destructors Virtual functions Single inheritance Multiple inheritance RTTI Templates Exceptions Operator Overloading How C++ Works 1 Overview Constructors and destructors Virtual functions Single inheritance Multiple inheritance RTTI Templates Exceptions Operator Overloading Motivation There are lot of myths about C++

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

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

IT 540 Operating Systems ECE519 Advanced Operating Systems

IT 540 Operating Systems ECE519 Advanced Operating Systems IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (3 rd Week) (Advanced) Operating Systems 3. Process Description and Control 3. Outline What Is a Process? Process

More information

IA-32 Architecture. CS 4440/7440 Malware Analysis and Defense

IA-32 Architecture. CS 4440/7440 Malware Analysis and Defense IA-32 Architecture CS 4440/7440 Malware Analysis and Defense Intel x86 Architecture } Security professionals constantly analyze assembly language code } Many exploits are written in assembly } Source code

More information

Exceptions and Processes

Exceptions and Processes Exceptions and Processes Much of the material for this lecture is drawn from Computer Systems: A Programmer s Perspective (Bryant & O Hallaron) Chapter 8 1 Goals of this Lecture Help you learn about: Exceptions

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

Major Requirements of an OS

Major Requirements of an OS Process CSCE 351: Operating System Kernels Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization while providing reasonable response time Allocate

More information

Project 2: Signals. Consult the submit server for deadline date and time

Project 2: Signals. Consult the submit server for deadline date and time Project 2: Signals Consult the submit server for deadline date and time You will implement the Signal() and Kill() system calls, preserving basic functions of pipe (to permit SIGPIPE) and fork (to permit

More information

Whatever can go wrong will go wrong. attributed to Edward A. Murphy. Murphy was an optimist. authors of lock-free programs 3.

Whatever can go wrong will go wrong. attributed to Edward A. Murphy. Murphy was an optimist. authors of lock-free programs 3. Whatever can go wrong will go wrong. attributed to Edward A. Murphy Murphy was an optimist. authors of lock-free programs 3. LOCK FREE KERNEL 309 Literature Maurice Herlihy and Nir Shavit. The Art of Multiprocessor

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

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

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

Process Description and Control. Chapter 3

Process Description and Control. Chapter 3 Process Description and Control Chapter 3 Contents Process states Process description Process control Unix process management Process From processor s point of view execute instruction dictated by program

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

Lecture Dependable Systems Practical Report Software Implemented Fault Injection. July 31, 2010

Lecture Dependable Systems Practical Report Software Implemented Fault Injection. July 31, 2010 Lecture Dependable Systems Practical Report Software Implemented Fault Injection Paul Römer Frank Zschockelt July 31, 2010 1 Contents 1 Introduction 3 2 Software Stack 3 2.1 The Host and the Virtual Machine.....................

More information

Addressing Modes. Outline

Addressing Modes. Outline Addressing Modes Chapter 11 S. Dandamudi Outline Addressing modes Simple addressing modes Register addressing mode Immediate addressing mode Memory addressing modes 16-bit and 32-bit addressing» Operand

More information

Process Description and Control. Major Requirements of an Operating System

Process Description and Control. Major Requirements of an Operating System Process Description and Control Chapter 3 1 Major Requirements of an Operating System Interleave the execution of several processes to maximize processor utilization while providing reasonable response

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

Major Requirements of an Operating System Process Description and Control

Major Requirements of an Operating System Process Description and Control Major Requirements of an Operating System Process Description and Control Chapter 3 Interleave the execution of several processes to maximize processor utilization while providing reasonable response time

More information

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,... COMPUTER ARCHITECTURE II: MICROPROCESSOR PROGRAMMING We can study computer architectures by starting with the basic building blocks Transistors and logic gates To build more complex circuits Adders, decoders,

More information

Objectives. Introduction to process management of an operating system Explain step-by-step how processes are created in TOS

Objectives. Introduction to process management of an operating system Explain step-by-step how processes are created in TOS TOS Arno Puder 1 Objectives Introduction to process management of an operating system Explain step-by-step how processes are created in TOS 2 Introduction to Processes What is a process? A process consists

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

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

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D) MANAGEMENT OF APPLICATION EXECUTION PROCESS CONTROL BLOCK Resources (processor, I/O devices, etc.) are made available to multiple applications The processor in particular is switched among multiple applications

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

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

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

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

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

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

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture. Chapter Overview.

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture. Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 2: IA-32 Processor Architecture Slides prepared by Kip R. Irvine Revision date: 09/25/2002 Chapter corrections (Web) Printing

More information

printf("this program adds the value 10 to a given integer number.\n\n");

printf(this program adds the value 10 to a given integer number.\n\n); PA1 Sample Solution Program 1 void add10(int *n); //Prototype int n; printf("this program adds the value 10 to a given integer number.\n\n"); printf("please enter an integer number: "); scanf("%d", &n);

More information

Subprograms: Local Variables

Subprograms: Local Variables Subprograms: Local Variables ICS312 Machine-Level and Systems Programming Henri Casanova (henric@hawaii.edu) Local Variables in Subprograms In all the examples we have seen so far, the subprograms were

More information

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed Process Management CS 537 Lecture 3: Processes Michael Swift This lecture begins a series of topics on processes, threads, and synchronization Today: processes and process management what are the OS units

More information

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1 Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD 21252 rkarne@towson.edu 11/12/2014 Slide 1 Intel x86 Aseembly Language Assembly Language Assembly Language

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

Overview. Constructors and destructors Virtual functions Single inheritance Multiple inheritance RTTI Templates Exceptions Operator Overloading

Overview. Constructors and destructors Virtual functions Single inheritance Multiple inheritance RTTI Templates Exceptions Operator Overloading HOW C++ WORKS Overview Constructors and destructors Virtual functions Single inheritance Multiple inheritance RTTI Templates Exceptions Operator Overloading Motivation There are lot of myths about C++

More information

Exceptions. user mode. software should run in supervisor mode Certain features/privileges il are only allowed to code running in supervisor mode

Exceptions. user mode. software should run in supervisor mode Certain features/privileges il are only allowed to code running in supervisor mode Status Register EE 357 Unit 9 Exceptions Used for debugging; when set, it can be used to pause the CPU after execution of each instruction Coldfirecan run programs in two modes: supervisor mode (for OS

More information

Windows Interrupts

Windows Interrupts Windows 2000 - Interrupts Ausgewählte Betriebssysteme Institut Betriebssysteme Fakultät Informatik 1 Interrupts Software and Hardware Interrupts and Exceptions Kernel installs interrupt trap handlers Interrupt

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

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