Lecture Introduction to computing systems (2/e): Chapter 9 - Yale N. Patt, Sanjay J. Patel

Chapter 9 - TRAP routines and subroutines. This chapter presents the following content: The TRAP mechanism, the trap instruction, the complete mechanism, TRAP routines for handling I/O, TRAP routine for halting the computer, saving and restoring registers, the call/return mechanism, | Chapter 9 TRAP Routines and Subroutines System Calls Certain operations require specialized knowledge and protection: specific knowledge of I/O device registers and the sequence of operations needed to use them I/O resources shared among multiple users/programs; a mistake could affect lots of other users! Not every programmer knows (or wants to know) this level of detail Provide service routines or system calls (part of operating system) to safely and conveniently perform low-level, privileged operations 9- System Call 1. User program invokes system call. 2. Operating system code performs operation. 3. Returns control to user program. In LC-2, this is done through the TRAP mechanism. 9- LC-2 TRAP Mechanism 1. A set of service routines. part of operating system -- routines start at arbitrary addresses (convention is that system code is below x3000 or above xCFFF) up to 256 routines 2. Table of starting addresses. stored at x0000 through x00FF in memory (but text says that 0x0000 through 0x001F mustn’t be used) called System Control Block in some architectures 3. TRAP instruction. used by program to transfer control to operating system 8-bit trap vector names one of the 256 service routines 4. RET instruction. returns control to the user program execution resumes immediately after the TRAP instruction 9- TRAP Instruction Trap vector identifies which system call to invoke 8-bit index into table of service routine addresses in LC-2, this table is stored in memory at 0x0000 – 0x00FF 8-bit trap vector is zero-extended into 16-bit memory address Where to go lookup starting address from table; place in PC How to get back save address of next instruction (current PC) in R7 9- TRAP NOTE: PC has already been incremented during instruction fetch stage. 9- RET Instruction Put contents of R7 into PC when used at the end of a service routine, sends control back to user program, just after TRAP instruction (unless service routine changes contents of R7) Note: . | Chapter 9 TRAP Routines and Subroutines System Calls Certain operations require specialized knowledge and protection: specific knowledge of I/O device registers and the sequence of operations needed to use them I/O resources shared among multiple users/programs; a mistake could affect lots of other users! Not every programmer knows (or wants to know) this level of detail Provide service routines or system calls (part of operating system) to safely and conveniently perform low-level, privileged operations 9- System Call 1. User program invokes system call. 2. Operating system code performs operation. 3. Returns control to user program. In LC-2, this is done through the TRAP mechanism. 9- LC-2 TRAP Mechanism 1. A set of service routines. part of operating system -- routines start at arbitrary addresses (convention is that system code is below x3000 or above xCFFF) up to 256 routines 2. Table of starting addresses. stored at x0000 through x00FF in memory (but text says that .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
10    69    2    22-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.