CS 241 Section Week #10 (04/01/10) ‏. Topics This Section  MP5 Overview  Signals.

Slides:



Advertisements
Similar presentations
Recitation 8: 10/28/02 Outline Processes Signals –Racing Hazard –Reaping Children Annie Luo Office Hours: Thursday 6:00.
Advertisements

CS 542: Topics in Distributed Systems Diganta Goswami.
Week Fourteen Agenda Announcements Final Exam True/False -100 questions (1 point per question) Multiple Choice - 40 questions (2 points per question)
15-213, Fall 06 Outline Shell Lab Processes Signals.
Processes and Job Control. Foreground and Background (1)  Unix is a multi-tasking operating system –some of these tasks are being done by other users.
System Programming Project 2 Due : 4/19...?. Foreground & Background Foreground job Foreground job Only one at moment Only one at moment Having user’s.
CSE 451: Operating Systems Section 6 Project 2b; Midterm Review.
Events and Interrupts. Overview  What is an Event?  Examples of Events  Polling  Interrupts  Sample Timer Interrupt example.
UNIX Process Control Bach 7 Operating Systems Course Hebrew University Spring 2007.
CS Lecture 17 Outline Named pipes Signals Lecture 17
Signals Hua LiSystems ProgrammingCS2690Signals. Topics: Sending Signals -- kill(), raise() Signal Handling -- signal() sig_talk.c -- complete example.
Operating Systems Course Hebrew University Spring 2007 Signals & User Thread.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Threads and Scheduling 6.
CS Lecture 16 Outline Inter-process Communication (IPC) – Pipes – Signals Lecture 161CS Operating Systems 1.
Signal Signal : - is a notification sent to a process to notify it of some event - interrupts whatever the process is doing and force it to handle a signal.
Signals, Synchronization CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Processes, Signals, I/O, Shell lab
CSc 352 Signal Handling in Unix Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
Carnegie Mellon 1 Processes, Signals, I/O, Shell Lab : Introduction to Computer Systems Recitation 9: 10/21/2013 Tommy Klein Section B.
UNIX Processes. The UNIX Process A process is an instance of a program in execution. Created by another parent process as its child. One process can be.
UNIX Signals Bach 7.2 Operating Systems Course The Hebrew University Spring 2010.
Signals & Timers CS241 Discussion Section Spring 2009 Week 6.
Inter-Process Communication Mechanisms CSE331 Operating Systems Design.
1Reference “Introduction To Unix Signals Programming” in the reference material section Man page – sigprocmask, alarm “Understanding the Linux Kernel”
Recitation 9: Section L (1:30pm - 2:20pm) Monday, October 22, 2012 Processes, Signals and Shell Lab Siddharth Dhulipalla.
The process concept (section 3.1, 3.3 and demos)  Process: An entity capable of requesting and using computer resources (memory, CPU cycles, files, etc).
1 Logging in to a UNIX System init ( Process ID 1 created by the kernel at bootstrap ) spawns getty for every terminal device invokes our login shell terminal.
CS 346 – Chapter 4 Threads –How they differ from processes –Definition, purpose Threads of the same process share: code, data, open files –Types –Support.
Florida State UniversityCOP5570 – Advanced Unix Programming Today’s topics System V Interprocess communication (IPC) mechanisms –Message Queues –Semaphores.
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
Lecture 24CS311 – Operating Systems 1 1 CS311 – Lecture 24 Outline Final Exam Study Guide Note: These lecture notes are not intended replace your notes.
Scis.regis.edu ● CS 468: Advanced UNIX Class 5 Dr. Jesús Borrego Regis University 1.
4.1 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Project1: Unix Shell with History Feature Goals Descriptions Methodology Submission.
IPC Programming. Process Model Processes can be organized into a parent-child hierarchy. Consider the following example code: /* */
UNIX Socket Programming CS 6378 Project Reference Book: Unix Network programming: Networking APIs: Sockets and XTI (2nd edition), Prentice Hall >> Threads.
Process Models, Creation and Termination Reference –text: Tanenbaum ch. 2.1.
Signals and Signal Processing CIS 370 Lab 7 Umass Dartmouth.
Outline for Today Objectives –Finish discussion of Birrell –UNIX Signals –Eraser Administrative –Spider talk after class.
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.
NCHU System & Network Lab Lab #8 Signals Operating System Lab.
1 Signals (continued) CS 241 April 9, 2012 University of Illinois.
SignalsSignals. What is a Signal? A signal is a notification that some event has occurred. Usually a signal is sent to a process asynchronously and whatever.
UNIX Signals * POSIX-Defined Signals * Signaling Processes * Signal Mask * sigaction * kill and sigaction * alarm * Interval Timers * POSIX.1b Timers *
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 4: Threads Overview Multithreading Models Threading Issues.
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.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Today’s topic Environment variables Signal. The list of environment variables –try ‘env’ –Environment variables can be defined in shell setenv DISPLAY.
Chapter 8 Signals Source: Robbins and Robbins, UNIX Systems Programming, Prentice Hall, 2003.
Advanced UNIX progamming Fall 2002 Instructor: Ashok Srinivasan Lecture 9 Acknowledgements: The syllabus and power point presentations are modified versions.
Today’s topics Signals and how to control the program behavior in handling signals. Terminal I/O.
Signals & Message queue Inter process mechanism in Linux system 3/24/
1 CSE 451 Section 2: Processes, the shell, and system calls.
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.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Signals.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Signals.
1.3 System Call. System Call System calls provide the interface between a running program and the operating system. System call is a method by which a.
CSE 451: Operating Systems Section 6 Project 2b. Midterm  Scores will be on Catalyst and midterms were handed back on Friday(?) in class  Talk to Ed,
Operating Systems Practical Session 3, Signals 1.
G.Jyostna.
User-Written Functions
Unix Process Management
OS – Process Creation and Destruction
UNIX PROCESSES.
Tarek Abdelzaher Vikram Adve Marco Caccamo
Exceptional Control Flow Part II
Project1: Unix Shell using Multi-Processing
CSC Advanced Unix Programming, Fall 2015
OS – Process Creation and Destruction
Controlling Processes
Signals.
Presentation transcript:

CS 241 Section Week #10 (04/01/10) ‏

Topics This Section  MP5 Overview  Signals

MP5 Overview MP5 looks at a modern programming paradigm that was popularized by Google called “MapReduce”. Specifically, you’ll be gathering statistics on newsgroup files via multiple processes and delivering them back to the MONITOR, a piece of code we provide for you.

MP5 Overview You have three key resources to help you understand and program MP5: The README.txt A “high-level” README (PDF, found in the announcement newsgroup) A presentation entirely focused on MP5 details (PPT/Powerpoint, found in the announcement newsgroup)

MP5 Overview

MP5: Warnings! Closing your shared memory is IMPORTANT! Shared memory is a system-wide resource, not a user- wide resource. Excessive open shared memory resources can cause problems in other programs – don’t do it! When you’re done programming for the night, run:./cleanmemory.sh and make sure your program is running: shmctl(shmid, IPC_RMID, &buf);

MP5: Warnings! Ensuring you’re not fork-bombing is CRITICAL! If you’re running fork() inside a loop, or if your fork()’d program ended up inside an infinite loop, MAKE SURE your loops terminates. (Test your program with printf() calls before you add fork() calls.) Before running your program, you can run: bash (unless you’re already using bash) ulimit -u 64 (set your session max processes)

MP5: Warnings! If you have excessive processes after your program exits: ps -af | grep NetID: wfagen :37 pts/117 00:00:00./mapreduce wfagen :41 pts/117 00:00:00./mapreduce wfagen :51 pts/117 00:00:00./mapreduce kill -9 the processes you want to kill: kill kill kill

Signals As you learned in lecture, signals are simply asynchronous notifications delivered to your program. Every signal that is delivered must be acted upon! By default, every signal has a “default action” As a programmer, you can redefine what action some of the signals perform when they’re delivered.

Example Signals You already use signals all the time: SIGINT: SIGnal to INTerrupt execution. (Ctrl+C will sent this signal to the currently running process in a shell window.) Default Action: Terminate Process SIGSEGV: Signal of invalid memory reference. (This is the signal the kernel sends to your program when a segmentation fault occurs.) Default Action: Terminate Process

Signals There are two primary ways of changing the default behavior of signals: Signal Handler: Run a specific piece of code when a specific signal is delivered. Function Calls: sigaction(), signal() Block Signal: Acknowledges the signal, possibly blocking until it’s received. Function Calls: sigwait(), sigsuspend(), sigprocmask()

Signal Sets Many of the signal calls require the use of a “signal set” (sigset_t *set parameter). This “signal set” works like a mathematical set, where you can either start with: a set of all signals (sigfullset()) OR a set of no signals (sigemptyset()) And you can: add signals to the set (sigaddset()) OR remove signals (sigremoveset())

Signal Magic You have everything you need to program a signal!

Signal Example Goal: Run a function upon receiving SIGINT. struct sigaction action; action.sa_handler = my_function; sigemptyset (&action.sa_mask); action.sa_flags = 0; sigaction(SIGINT, &action, NULL);

Signal Example Goal: Block SIGINT from terminating the program (but don’t run any function). sigset_t set, oldset; sigemptyset(&set); sigaddset(&set, SIGINT); sigprocmask(SIG_BLOCK, &set, &oldset);

Signal Magic Like many things in C, there are multiple ways to accomplish the same end result. In MP5, you’ll need to both send signals and catch signals. You’ll find the provided MONITOR will help you out with some signal code. Lecture and these slides also provide great resources.