Outline for Today Objectives –Finish discussion of Birrell –UNIX Signals –Eraser Administrative –Spider talk after class.

Slides:



Advertisements
Similar presentations
Process Management.
Advertisements

Recitation 8: 10/28/02 Outline Processes Signals –Racing Hazard –Reaping Children Annie Luo Office Hours: Thursday 6:00.
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
1 CS345 Operating Systems Φροντιστήριο Άσκησης 1.
CSCC69: Operating Systems
15-213/ Intro to Computer Systems by btan with reference to Spring 10’s slides.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
UNIX Process Control Bach 7 Operating Systems Course Hebrew University Spring 2007.
Process Process: the UNIX abstraction of a stand-along computer that manages resources (memory, CPU, I/O resources) comprising a running program. Processes.
Signals Hua LiSystems ProgrammingCS2690Signals. Topics: Sending Signals -- kill(), raise() Signal Handling -- signal() sig_talk.c -- complete example.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Threads and Scheduling 6.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CS Lecture 16 Outline Inter-process Communication (IPC) – Pipes – Signals Lecture 161CS Operating Systems 1.
CSSE Operating Systems
Section A (March 14) Outline Exceptions Process Signals Non-local jumps Reminders Lab4: Due Next Thursday TA: Kun Gao Shamelessly Modified from Minglong.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Processes, Signals, I/O, Shell lab
CSc 352 Signal Handling in Unix Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
System Structuring with Threads. Example: A Transcoding Web Proxy Appliance “Proxy” Interposed between Web (HTTP) clients and servers. Masquerade as (represent)
UNIX Signals Bach 7.2 Operating Systems Course The Hebrew University Spring 2010.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
1Reference “Introduction To Unix Signals Programming” in the reference material section Man page – sigprocmask, alarm “Understanding the Linux Kernel”
Outline for Today Announcements –Keep those group s coming… –What I learned from Who’s who forms Objective of the lecture –Abstractions provided by.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
1 Outline Objective: –Get specific with UNIX system calls –Continue with message-passing style interprocess communication (IPC) – including UNIX example.
Lecture Thread: Unix process-oriented system calls
Operating Systems CSE 411 CPU Management Sept Lecture 9 Instructor: Bhuvan Urgaonkar.
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
System calls for Process management
Chapter 11 Process Management
Unix Process Model Simple and powerful primitives for process creation and initialization. fork syscall creates a child process as (initially) a clone.
Scis.regis.edu ● CS 468: Advanced UNIX Class 5 Dr. Jesús Borrego Regis University 1.
Signals (Chap 10 in the book “Advanced Programming in the UNIX Environment”) Acknowledgement : Prof. Y. Moon at Kangwon Nat’l Univ.
UNIX Socket Programming CS 6378 Project Reference Book: Unix Network programming: Networking APIs: Sockets and XTI (2nd edition), Prentice Hall >> Threads.
Concurrent Processes Processes can concurrently run same program. Processes can concurrently run same program. Processes can start other processes. Processes.
Operating Systems Process Creation
Signals and Signal Processing CIS 370 Lab 7 Umass Dartmouth.
Signals and Signal Handling. Signals A predefined message sent between two processes or from the kernel to a process, or by a user to a process A software.
Signals (Chap 10 in the book “Advanced Programming in the UNIX Environment”) Acknowledgement : Prof. Y. Moon at Kangwon Nat’l Univ.
1 Signals (continued) CS 241 April 9, 2012 University of Illinois.
UNIX Signals * POSIX-Defined Signals * Signaling Processes * Signal Mask * sigaction * kill and sigaction * alarm * Interval Timers * POSIX.1b Timers *
Signals. Introduction r A signal is a mechanism for notifying a process that an event has occurred. m When a signal is sent to a process is normal execution.
© 숙대 창병모 1 제 10 장 신호 (Signal). © 숙대 창병모 2 Contents 1. Signal Concepts 2. signal() 3. Interrupted System Calls 4. kill() /raise() 5. alarm() pause() 6.
Linux/UNIX Programming APUE (Signals) [Ch. 10] 최미정 강원대학교 컴퓨터과학전공.
Managing Processors Jeff Chase Duke University. The story so far: protected CPU mode user mode kernel mode kernel “top half” kernel “bottom half” (interrupt.
Operating Systems CMPSC 473 Signals, Introduction to mutual exclusion September 28, Lecture 9 Instructor: Bhuvan Urgaonkar.
S -1 Processes. S -2 wait and waitpid (11.2) Recall from a previous slide: pid_t wait( int *status ) wait() can: (a) block; (b) return with status; (c)
System calls for Process management Process creation, termination, waiting.
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
1 Lecture 19: Unix signals and Terminal management n what is a signal n signal handling u kernel u user n signal generation n signal example usage n terminal.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
1 Outline for Today Objective: –Continue with message-passing style interprocess communication (IPC) –Get specific with UNIX system calls Administrative.
Process Manipulation. Process Manipulation in UNIX Basic process manipulation: creation, program loading, exiting, … fork(), exec(), wait(), exit() Process.
G.Jyostna.
Unix Process Management
제11장 프로세스 시스템 프로그래밍 2011 가을 숙명여대 창병모.
Exceptional Control Flow Part II
Structure of Processes
Processes in Unix, Linux, and Windows
Exceptional Control Flow
Processes in Unix, Linux, and Windows
제11장 프로세스 관리.
Exceptional Control Flow
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix, Linux, and Windows
Process Description and Control in Unix
Presentation transcript:

Outline for Today Objectives –Finish discussion of Birrell –UNIX Signals –Eraser Administrative –Spider talk after class

Alerts Thread state contains flag, alert-pending Exception alerted Alert (thread) alert-pending to true, wakeup a waiting thread AlertWait (mutex, condition) if alert-pending set to false and raise exception else wait as usual Boolean b = TestAlert() tests and clear alert-pending TRY while (empty) AlertWait (m, nonempty); return (nextchar()); EXCEPT Thread.Alerted: return (eof);

Using Alerts sibling = Fork (proc, arg); while (!done) { done = longComp(); if (done) Alert (sibling); else done = TestAlert(); }

Wisdom Do s Reserve using alerts for when you don’t know what is going on Only use if you forked the thread Impose an ordering on lock acquisition Write down invariants that should be true when locks aren’t being held Don’t s Call into a different abstraction level while holding a lock Move the “last” signal beyond scope of Lock Acquire lock, fork, and let child release lock Expect priority inheritance since few implementations Pack data and expect fine grain locking to work

Signals Signals notify processes of internal or external events. –the Unix software equivalent of interrupts/exceptions –only way to do something to a process “from the outside” –Unix systems define a small set of signal types Examples of signal generation: –keyboard ctrl-c and ctrl-z signal the foreground process –synchronous fault notifications, syscall errors –asynchronous notifications from other processes via kill –IPC events (SIGPIPE, SIGCHLD) –alarm notifications signal == “upcall”

Process Handling of Signals 1. Each signal type has a system-defined default action. abort and dump core (SIGSEGV, SIGBUS, etc.) ignore, stop, exit, continue 2. A process may choose to block (inhibit) or ignore some signal types. 3. The process may choose to catch some signal types by specifying a (user mode) handler procedure. specify alternate signal stack for handler to run on system passes interrupted context to handler handler may munge and/or return to interrupted context

Using Signals int alarmflag=0; alarmHandler () { printf(“An alarm clock signal was received\n”); alarmflag = 1; } main() { signal (SIGALRM, alarmHandler); alarm(3); printf(“Alarm has been set\n”); while (!alarmflag) pause (); printf(“Back from alarm signal handler\n”); } Suspends caller until signal Instructs kernel to send SIGALRM in 3 seconds Sets up signal handler

User’s View of Signals II main() { int (*oldHandler) (); printf (“I can be control-c’ed\n”); sleep (3); oldHandler = signal (SIGINT, SIG_IGN); printf(“I’m protected from control-c\n”); sleep(3); signal (SIGINT, oldHandler); printf(“Back to normal\n”); sleep(3); printf(“bye\n”); }

Yet Another User’s View main(argc, argv) int argc; char* argv[]; { int pid; signal (SIGCHLD,childhandler); pid = fork (); if (pid == 0) /*child*/ { execvp (argv[2], &argv[2]); } else {sleep (5); printf(“child too slow\n”); kill (pid, SIGINT); } childhandler() {int childPid, childStatus; childPid = wait (&childStatus); printf(“child done in time\n”); exit; } SIGCHLD sent by child on termination; if SIG_IGN, dezombie Collects status

Delivering Signals 1. Signal delivery code always runs in the process context. 2. All processes have a trampoline instruction sequence installed in user-accessible memory. 3. Kernel delivers a signal by doctoring user context state to enter user mode in the trampoline sequence. First copies the trampoline stack frame out to the signal stack. 4. Trampoline sequence invokes the signal handler. 5. If the handler returns, trampoline returns control to kernel via sigreturn system call. Handler gets a sigcontext (machine state) as an arg; handler may modify the context before returning from the signal.

When to Deliver Signals? run user run kernel ready blocked run wakeup trap/fault sleep preempted suspend/run new fork zombie exit swapout/swapin (suspend) Interrupt low- priority sleep if signal is posted. Check for posted signals after wakeup. Deliver signals when resuming to user mode. Deliver signals when returning to user mode from trap/fault.