filmov
tv
Operating System #16 Software Interrupts | System calls in xv6

Показать описание
Operating System #16 Software Interrupts | System calls in xv6
00:29 Hardware vs Software Interrupt:
- In Hardware Interrupt, a device (like the PIC) asserts a pin in the CPU.
- In Software Interrupt, An instruction which when executed causes an interrupt.
Software interrupt used for implementing system calls
– In Linux INT 128, is used for system calls
– In xv6, INT 64 is used for system calls.
03:20 Example (write system call)
05:28 System Calls in xv6
07:10 System Call Number
09:36 Prototype of a typical System Call: int system_call( resource_descriptor, parameters)
- int: return is generally ‘int’ (or equivalent) sometimes ‘void’. int used to denote completion status of system call sometimes also has additional information like number of bytes written to file.
- resource_descriptor: What OS resource is the target here? For example a file, device, etc. If not specified, generally means the current process.
- parameters: System call specific parameters passed.
13:49 Passing Parameters in System Calls: ssize_t write(int fd, const void *buf, size_t count);
• Passing parameters to system calls not similar to passing parameters in function calls.
– Recall stack changes from user mode stack to kernel stack.
• Typical Methods
– Pass by Registers (eg. Linux)
– Pass via user mode stack (eg. xv6)
• Complex
– Pass via a designated memory region
• Address passed through registers
14:42 Pass By Registers (Linux):
• System calls with fewer than 6 parameters passed in registers
– %eax (sys call number), %ebx, %ecx,, %esi, %edi, %ebp
• If 6 or more arguments
– Pass pointer to block structure containing argument list
15:42 Pass via User Mode Stack (xv6)
15:22 Returns from System Calls
00:29 Hardware vs Software Interrupt:
- In Hardware Interrupt, a device (like the PIC) asserts a pin in the CPU.
- In Software Interrupt, An instruction which when executed causes an interrupt.
Software interrupt used for implementing system calls
– In Linux INT 128, is used for system calls
– In xv6, INT 64 is used for system calls.
03:20 Example (write system call)
05:28 System Calls in xv6
07:10 System Call Number
09:36 Prototype of a typical System Call: int system_call( resource_descriptor, parameters)
- int: return is generally ‘int’ (or equivalent) sometimes ‘void’. int used to denote completion status of system call sometimes also has additional information like number of bytes written to file.
- resource_descriptor: What OS resource is the target here? For example a file, device, etc. If not specified, generally means the current process.
- parameters: System call specific parameters passed.
13:49 Passing Parameters in System Calls: ssize_t write(int fd, const void *buf, size_t count);
• Passing parameters to system calls not similar to passing parameters in function calls.
– Recall stack changes from user mode stack to kernel stack.
• Typical Methods
– Pass by Registers (eg. Linux)
– Pass via user mode stack (eg. xv6)
• Complex
– Pass via a designated memory region
• Address passed through registers
14:42 Pass By Registers (Linux):
• System calls with fewer than 6 parameters passed in registers
– %eax (sys call number), %ebx, %ecx,, %esi, %edi, %ebp
• If 6 or more arguments
– Pass pointer to block structure containing argument list
15:42 Pass via User Mode Stack (xv6)
15:22 Returns from System Calls
Комментарии