Tips for R3: Process Initialization When we create processes to represent our 5 test procedures we must correctly initialize its context by placing values.

Slides:



Advertisements
Similar presentations
Programming 8086 – Part IV Stacks, Macros
Advertisements

Register In computer architecture, a processor register is a small amount of storage available on the CPU whose contents can be accessed more quickly than.
Registers of the 8086/ /2002 JNM.
The University of Adelaide, School of Computer Science
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
CS 450 Module R4. R4 Overview Due on March 11 th along with R3. R4 is a small yet critical part of the MPX system. In this module, you will add the functionality.
CS 450 Module R3. Next Week R2 is due next Friday ▫Make sure to correct all errors with R1 ▫Correct errors in the documentation as well, it will be checked.
There are two types of addressing schemes:
Module R2 Overview. Process queues As processes enter the system and transition from state to state, they are stored queues. There may be many different.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
Procedures and Stacks. Outline Stack organization PUSH and POP instructions Defining and Calling procedures.
Flow Diagram: Push flags, CS, IP Pop IP,CS,flags Push AX,BX,CX,DX,ES,DS,SI,DI,BP POP BP,DI,SI,DS,ES,DX,CX,BX,AX.
Azir ALIU 1 What is an assembly language?. Azir ALIU 2 Inside the CPU.
Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks.
1 Storage Registers vs. memory Access to registers is much faster than access to memory Goal: store as much data as possible in registers Limitations/considerations:
Processes CSCI 444/544 Operating Systems Fall 2008.
Interrupt Processing Haibo Wang ECE Department
Processes 1 CS502 Spring 2006 Processes Week 2 – CS 502.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Gursharan Singh Tatla Block Diagram of Intel 8086 Gursharan Singh Tatla 19-Apr-17.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
CS 450 Module R6. Next Week R5 is due Friday after Break ( April 1st ) ▫No documentation, no source code due ▫R5 is stand-alone, so I will not be checking.
Introduction to Processes CS Intoduction to Operating Systems.
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
Stack Operations LIFO structure (last-in,first-out) –The last value put into the stack is the first value taken out Runtime stack –A memory array that.
Types of Registers (8086 Microprocessor Based)
Implementing function/ procedure calls (in Pascal and C)
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Device Drivers CPU I/O Interface Device Driver DEVICECONTROL OPERATIONSDATA TRANSFER OPERATIONS Disk Seek to Sector, Track, Cyl. Seek Home Position.
CS 450 Module R3. Today's Agenda R1 and R2 review Module R3 Introduction Schedule R1 Grading Next Week Module R4 Introduction.
Module R3 Process Scheduling. Module R3 involves the creation of a simple “Round Robin” dispatcher. The successful completion of this module will require.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
Microprocessor Microprocessor (cont..) It is a 16 bit μp has a 20 bit address bus can access upto 220 memory locations ( 1 MB). It can support.
6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.
Interrupts And tips for R3. What is an interrupt? An interrupt is an electronic signal that indicates an event (possibly caused by hardware or the program.
Preocedures A closer look at procedures. Outline Procedures Procedure call mechanism Passing parameters Local variable storage C-Style procedures Recursion.
Internal Programming Architecture or Model
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
ΜComputer Structure μProcessor Memory Bus System I/O Ports.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Stack Operations Dr. Hadi AL Saadi.
Instructions for test_function
Processes and threads.
Process concept.
Format of Assembly language
Microprocessor and Assembly Language
Protection of System Resources
Introduction to 8086 Microprocessor
8086 Microprocessor.
University of Gujrat Department of Computer Science
Intel 8088 (8086) Microprocessor Structure
Chapter 3 Addressing Modes
Symbolic Instruction and Addressing
Intel 8088 (8086) Microprocessor Structure
8086 Registers Module M14.2 Sections 9.2, 10.1.
CS-401 Computer Architecture & Assembly Language Programming
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
The University of Adelaide, School of Computer Science
Symbolic Instruction and Addressing
Lecture 06 Programming language.
Computer Architecture CST 250
Unit-I 80386DX Architecture
Low-Level Thread Dispatching on the x86
Chapter 6 –Symbolic Instruction and Addressing
Process.
Intel 8086.
Part I Data Representation and 8086 Microprocessors
(The Stack and Procedures)
Presentation transcript:

Tips for R3: Process Initialization When we create processes to represent our 5 test procedures we must correctly initialize its context by placing values into its stack, data segment and extra segment.

1) We need to define a special global structure to represent the “context” of a process which is automatically saved onto the processes stack when the process is interrupted: typedef struct context { unsigned int BP, DI, SI, DS, ES; unsigned int DX, CX, BX, AX; unsigned int IP, CS, FLAGS; } context; context *context_p;

Recall that: When an interrupt occurs the HARDWARE saves the flags register (PSW), CS (code segment), IP (instruction pointer) onto the stack in this order!!!!! Next because of the interrupt keyword being specified in the implementation of our interrupt handler: void interrupt sys_call_handler() Assembler instructions will be added to the routine to automatically save the following registers onto the stack: AX, BX, CX, DX, ES, DS, SI, DI, AND BP Code will also be automatically added at the end of the routine to restore these!!!!!

We need to set up the initial context of each process by initializing the contents of its stack. The declaration of the PCB should contain a pointer to a stack of size 1k, which should initially be initialized to all zeros!! The stack pointer should be initialized to the “highest” address in your stack (stack address +1024) (remember that the stack grows from high memory down.) We need to store the initial context of the process in the top portion of the stack!

Pcb.stack_p = pcb.stack_base + pcb.stack_size – sizeof(context); Context_p = (context *)pcb.stack_p; context_p->DS = _DS; context_p->ES = _ES; context_p->CS = FP_SEG(&testn_R3); context_p->IP = FP_OFF(&testn_R3); context_p->FLAGS = 0x200

Process cause interrupts by: Each process will voluntarily give up control of the CPU using a call to “sys_req” which will generate a system call interrupt. Processes call “sys_req” with two possible op_code values: IDLE: which will return the process to the ready queue IDLE: which will return the process to the ready queue EXIT: which is a request to terminate the process, and free the PCB. EXIT: which is a request to terminate the process, and free the PCB. This call to sys_req will result in an interrupt being generated which should be processed by our “sys_call_hander”

Setting up “sys_call_handler” During initialization you must set the “sys_call” vector to contain the address of your interrupt handler. It has the prototype: int sys_set_vec (void (*handler)()); The single parameter handler is a pointer to your system call handler. If your handler has the name sys_call, then it should have the prototype: void sys_call (void); Your call to sys_set_vec, which should occur during initialization, will have the form sys_set_vec(sys_call);

Sys_req passes a single parameter to your sys_call_handler, via the stack (previous stack contents) Buffer length pointer parameter (*count) Buffer address parameter (*buffer) Device_id parameter Op_code parameter FlagCSIPAXBXCXDXESDSSIDIBP We will need to retrieve the contents of the 1 st four parameters to identify the type of request made by the calling process.

To access these parameters we define another structure similar to the “context” structure: typedef struct params { int op_code; int device_id; byte *buf_addr; int *count_addr; } params;

We gain access to the op_code by: The stack structure must be a named type. A pointer to this structure is also required: params *param_p; Finally, the following assignment will set the pointer to the address of the actual stack frame to be accessed: param_p = (params*)(MK_FP(_SS,_SP) + sizeof(context)); It is now possible to refer to the op_code value as param_p->op_code.

We then need to interpret this code and take the appropriate action! First save a copy of the SS and SP and switch to another temporary stack. (local variables should be declared as static) #define SYS_STACK_SIZE 200 byte sys_stack[SYS_STACK_SIZE]; unsigned short ss_save; unsigned short sp_save; unsigned short new_ss; unsigned short new_sp; /* in syscall*/ ss_save = _SS; ss_save = _SS; sp_save = _SP; new_ss = FP_SEG(sys_stack); new_sp = FP_OFF(sys_stack); new_sp += SYS_STACK_SIZE; _SS = new_ss; SP = new_sp;

set param_p point to the correct place: cop->stack_ptr = (unsigned char *) MK_FP(_SS, _SP); param_p = (params *)(cop->stack_ptr + sizeof(context)); if parm_p->op_code is IDLE change the state of cop to ready insert cop to ready queue by priority else if param_p->op_code is EXIT delete the pcb set cop to NULL else set context_p->AX to error code. call dispatch()

In the dispatcher Automatically saves the data registers onto the temporary stack for the calling process Then a complete outline for the dispatcher is:

if sp_save is null, ss_save = _SS sp_save = _SP remove the PCB at the head of the ready queue if a PCB was found set cop to this PCB set _SS and _SP to the PCB's stack pointer else set cop to NULL set _SS to ss_save set _SP to sp_save end if "return from interrupt"