1 / 30

Project 2 Roadmap++

Project 2 Roadmap++. 1000 A’S. Review. Process B function handler() { Print “HANDLING” } main() { Signal(&handler, SIGUSR1) for(;;) Print “B” }. Process A main() { for(1000) Print “A” Kill(B, SIGUSR1) }. Output.

bessie
Download Presentation

Project 2 Roadmap++

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. Project 2 Roadmap++

  2. 1000 A’S Review Process B function handler() { Print “HANDLING” } main() { Signal(&handler, SIGUSR1) for(;;) Print “B” } Process A main() { for(1000) Print “A” Kill(B, SIGUSR1) } Output HANDLING BBBBBBBBBBBBBB….. AABBAABBAABB………

  3. System Calls • Sys_Signal:register a signal handler • Sys_Kill:send a signal • Sys_RegDeliver:initialize signal handling for a process • Sys_WaitNoPID:wait for any child process to die • Sys_ReturnSignal:indicate completion of signal handler

  4. System Calls • Sys_Signal:register a signal handler • Sys_Kill:send a signal • Sys_RegDeliver:initialize signal handling for a process • Sys_WaitNoPID:wait for any child process to die • Sys_ReturnSignal:indicate completion of signal handler Referenced in user code

  5. 1000 A’S Review Process B function handler() { Print “HANDLING” } main() { Signal(&handler, SIGUSR1) for(;;) Print “B” } Process A main() { for(1000) Print “A” Kill(B, SIGUSR1) } Output HANDLING BBBBBBBBBBBBBB….. AABBAABBAABB………

  6. System Calls • Sys_Signal:register a signal handler • Sys_Kill:send a signal • Sys_RegDeliver:initialize signal handling for a process • Sys_WaitNoPID:wait for any child process to die • Sys_ReturnSignal:indicate completion of signal handler

  7. Executed by stub code once a signal has been handled System Calls • Sys_Signal:register a signal handler • Sys_Kill:send a signal • Sys_RegDeliver:initialize signal handling for a process • Sys_WaitNoPID:wait for any child process to die • Sys_ReturnSignal:indicate completion of signal handler

  8. Helper Functions • Send_Signal • Set_Handler • Check_Pending_Signal • Setup_Frame • Complete_Handler

  9. Review Process B function handler() { Print “HANDLING” } main() { Signal(&handler, SIGUSR1) for(;;) Print “B” } Process A main() { for(1000) Print “A” Kill(B, SIGUSR1) }

  10. Overview A B

  11. Overview A B RegDeliver RegDeliver Signal(SIGCHILD) Signal(SIGCHILD, ….)

  12. Overview libc A B RegDeliver RegDeliver Signal(SIGCHILD) Signal(SIGCHILD, ….)

  13. Overview libc A B RegDeliver RegDeliver Signal(SIGCHILD) Signal(SIGCHILD, ….) Set_handler

  14. Overview libc A B RegDeliver RegDeliver Signal(SIGCHILD) Signal(SIGCHILD, ….) Set_handler

  15. libc A B RegDeliver RegDeliver Signal(SIGCHILD) Signal(SIGCHILD, ….) entry point main Kill Signal Overview Send_signal

  16. libc A B RegDeliver RegDeliver Signal(SIGCHILD) Signal(SIGCHILD, ….) entry point main Kill Signal Overview Send_signal

  17. libc A B RegDeliver RegDeliver Signal(SIGCHILD) Signal(SIGCHILD, ….) entry point main Kill Signal Overview

  18. Helper Functions • Send_Signal • Set_Handler • Check_Pending_Signal • Setup_Frame • Complete_Handler Look at Scheduler

  19. B Scheduler: w/o signals scheduler A B src/geekos/lowlevel.asm

  20. A B Scheduler: w/ signals scheduler B’s user level sig. hand. B

  21. A B Scheduler: w/ signals Check Pending Signal scheduler B’s user level sig. hand. B

  22. Check Pending Signal • Boolean output • Determines whether to proceed with signal handling

  23. true A B false Scheduler: w/ signals Check Pending Signal scheduler B’s user level sig. hand. B

  24. A B Scheduler: w/ signals Check Pending Signal Setup Frame scheduler B’s user level sig. hand. B

  25. Setup Frame • Sets up state to enable user-level handling code execution

  26. A B Scheduler: w/ signals Check Pending Signal Setup Frame scheduler B’s user level sig. hand. B

  27. Setup Frame • Sets up state to enable user-level handling code execution • How are function called?

  28. Function Calls • Parameter of return address is stored on the stack so when finished • Pop off stack • Continue execution • Setup Frame • Enables user stack to keep: • Interrupt_State Vector • Return address

  29. Storing Return Address • Want complete_handler to execute once user level handling done. • Hack • Place address of return_signal as return address on stack • Now return_signal stred as function

  30. A B Scheduler: w/ signals Check Pending Signal Setup Frame scheduler CompleteHandler B’s user level sig. hand. B

More Related