1 / 7

CMSC212: Intro to Low-Level Programming Concepts

CMSC212: Intro to Low-Level Programming Concepts. Section 0101: 9:00am – 9:50am Section 0102: 10:00am-10:50am Monday & Wednesdays Room 3118. Signals. Definition: A message that notifies the process of some event that occurred from the system.

dalit
Download Presentation

CMSC212: Intro to Low-Level Programming Concepts

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. CMSC212: Intro to Low-Level Programming Concepts Section 0101: 9:00am – 9:50am Section 0102: 10:00am-10:50am Monday & Wednesdays Room 3118

  2. Signals • Definition: A message that notifies the process of some event that occurred from the system. • Signals have corresponding numbers attached to them • However, not all signals must be handled by processes sent by the kernel

  3. Signals Types • Low-level ones: • SIGFPE (8): Divide by zero • SIGILL (4): Illegal instruction • SIGSEGV (11): Illegal memory reference (All familiar with this by now) • High-level ones (software events or in other processes): • SIGINT (2): Ctrl-c • SIGKILL(9): Forcibly terminate another process • SIGCHLD(17): When child process terminates/stops, kernel sends this to parent process

  4. Processes • Each process belongs to exactly one process group (PGID) • #include <unistd.h> • pid_t getpgrp(void); //returns PGID of calling process • int setpgid(pid_t pid, pid_t pgid); //returns 0 on success, -1 on failure • By default, processes belong to same ones as parent • To list the processes from the console: use ps

  5. Sending Signals • kill [-some signal #] [some process #] • kill -9 15213 (sends signal SIGKILL to process 15213) • kill -9 -15213 (sends signal SIGKILL to process group 15213) • Ctrl-c: Sends SIGINT to all processes of foreground process’s group • Ctrl-z: Sends SIGTSTP for stopping (suspending) • Demo:forkkill.c

  6. Sending Signals with alarm and sleep • Process may send signal SIGALARM to self by calling • Unsigned int alarm(unsigned int secs); //Returns remaining secs of previous alarm, or 0 if no previous alarm • Demo: signal1.c • Demo: signal2.c

  7. More on process control • wait(): will wait until all child processes have terminated • waitpid(pid): does the above except for a particular process id • Demo: childrenwait.c • int execvp(const char *filename, char *const argv[]);//Executes filename in current directory or in path as a new process image • Demo: execvtrivial.c

More Related