CS代写 COMP 3430 Operating Systems

COMP 3430 Operating Systems
IPC – signals and pipes

February 9th, 2022

Copyright By PowCoder代写 加微信 powcoder

By the end of today’s lecture, you should be able to:
▶ Write a UNIX program that send and handles signals.
▶ Describe what responsibilities an OS has in terms of implementing signals.
The Rocket Book (Public Domain)

Signals, in code
Traffic signals (Pixabay License)
Let’s look at fork-signal.c and answer some questions:
▶ Summarize what you expect the output to look like.
▶ When do statements get printed?
▶ What does the overall output look like? ▶ What does the parent process do?
▶ What does the child process do?

Signals you can’t hide from
Let’s look at signal.c and answer some questions:
▶ What do you expect to happen when you hit Ctrl+C (send SIGINT)?
▶ What do you expect to happen when you send SIGKILL? Options:
▶ Nothing is printed and the process ends (normal behaviour).
▶ “Handled signal {2,4}” is printed to the screen, then the
process ends.
▶ “Handled signal {2,4}” is printed to the screen, then the
process continues.
▶ We can’t predict what the output will be.

What’s the kernel doing?
▶ The kernel mediates this whole process. ▶ kill is a system call.
▶ The kernel performs a switch (context?
mode? …?)
▶ Let’s take a look at signal.c
More than this, I hope. (Pixabay License)

Everyone: Find out where the kill system call is implemented. Share the line number in chat.
Hint: Remember that system calls use the SYSCALL_DEFINE* macro.

Teams: Follow this as far as you can; can you find where the kernel actually sends a signal? Record your path and kinds of data structures you see!

Signals are great!
▶ We can send messages to our processes
▶ Kernel mediates the whole process.
Hand signals! (Public Domain)

1. We’re limited to the set of pre-defined signals. (… some of which we’re not even allowed to handle, see man 7 signal)
2. We can’t send any additional information outside of the signal.
3. We can’t send messages to processes on different machines
(COMP 3010).

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com