1 / 17

Concurrency, Processes, and System calls

Concurrency, Processes, and System calls. Benefits and issues of concurrency The basic concept of process System calls. Concurrency. Allows multiple applications to run at the same time Analogy: juggling. Benefits of Concurrency. What are the limitations without concurrency?

prem
Download Presentation

Concurrency, Processes, and System calls

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls

  2. Concurrency • Allows multiple applications to run at the same time • Analogy: juggling

  3. Benefits of Concurrency • What are the limitations without concurrency? • Long response time • Resources under utilized • Better resource utilization • Resources unused by one application can be used by the others • Better average response time • No need to wait for other applications to complete

  4. Benefits of Concurrency Keyboard CPU Disk Time Finishing time Keyboard CPU Disk

  5. Issues related to concurrency • It is easier to do one thing at a time. • Problems with doing multiple things: • Applications need to be protected from one another • Additional coordination mechanisms among applications • Overhead to switch among applications • Potential performance degradation when running too many applications

  6. Process • A process is a program in execution. • A process is a basic scheduling unit in an OS: during the execution, each process has a virtual machine. • The execution of processes does not interference with one another. • In a computer system, concurrency is realized by allowing multiple processes to co-exist at the same time. • Most programs are single process programs and the OS hides the details about creation and termination of processes.

  7. Process .vs. Program • Program: a collection of instructions • Process: a running instance of the program, with additional states and system resources • Example of additional states: process state (running, waiting, ready, etc) • Example of system resources: memory.

  8. Process != Program • Two processes can run the same program • The code segment of two processes are the same program • These two processes are totally independent of one another.

  9. Program != Process • A program can create multiple processes • Example: Internet Explorer

  10. Process context • It takes more than the “executable” to run a program. • Process context, sometimes also called process image, includes everything needed for the OS to run the program correctly. • Program counter • Stack pointer, etc

  11. System calls • System calls are functions (enhanced instructions) implemented in OS that can be used by user processes. • Handling system calls is like handling interrupts (sometimes call software interrupts). • Instead of a hardware event, the program issues an “interrupt” instruction. • All processors support such an instruction. The semantics of such instructions on different processors are similar (but have some slight differences). • On x86, the instruction is int/iret. • On MIPS, the instruction is syscall. • On some other older machines, the instruction is called trap.

  12. Void open (char *file_name) { asm { load OpenSystemCallNum, r8 move filename, r9 syscall } } • The semantic of the syscall instruction is similar to a routine call instruction. • The difference is that (1) the syscall handler address is obtained from the system call/interrupt vector (table) maintained by the OS; and (2) the mode is changed to the system mode. Interrupt vector 0x0 0x1 . . “Open” handler OpenSystemCallNum

  13. Question: The purpose of a system call is to invoke the system call handler routine. Why use the system call, instead of the simple routine call? • A system call changes the execution mode into system mode. • Some instruction can only be executed under the system mode. • Some services can only be provided correctly by the operating system due to the concurrency.

  14. Question: Is syscall a system mode instruction or a user mode instruction? • How about iret in x86?

  15. Typical sequence of events when running the syscall instruction: • Current program counter (PC) and program status word (PSW) are saved. • The program mode is changed to the system mode. • Hardware load PC from the system call interrupt vector location • Execute the system call interrupt handler • Change mode back to user mode • Restore PC and PSW and continue user program.

  16. System call interface • The system call interface is the description of the set of system calls supported by the OS. • The OS interface is pretty much defined by the system call interface. • Typical types of system calls • Process control • File management • Device management • Information management • Communication management

  17. Assuming that a system call and a routine performs the same task, which one will have better performance? • Homework!!

More Related