Do UNIX signals produce interrupts?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Do UNIX signals produce interrupts?
# 1  
Old 05-01-2015
Question Do UNIX signals produce interrupts?

Hi folks!

I have been reading Vahalia's Unix Internals book, which states the following in the chapter dedicated to signals:
Quote:
The receiving process becomes aware of the signal when the kernel calls the issig() function [...] The kernel calls issig() only at the following times:
  • Before returning to user mode from a syscall/interrupt
  • Just before blocking on an interruptible event
  • Immediatly after waking from an interruptible event
Given that, my understanding is that processes running in user mode don't become aware of signals until they switch to kernel mode, where the issig() function is called at some points.

However, he later gives an example where a user would type ctrl+c at a terminal, sending a SIGINT signal to the foreground process. If it happens that this process is running on another CPU, a special "cross-processor" interrupt is needed so that the target sees the signal. But why is that? Do signals actually produce interrupts (traps) to the signaled processes so they immediately see them? Otherwise, wouldn't it be enough to just set a flag in this process' structure, which would be then checked in one of that three situations described before?

Thanks in advance!
# 2  
Old 05-13-2015
Quote:
Originally Posted by Tru69
Do signals actually produce interrupts (traps) to the signaled processes so they immediately see them?
You seem to intuitively underlay your picture of how things work with the x86 architecture. While this is a very wide-spread platform there are very different designs on which UNIX/UNIX-like systems runs with the same ease as on Intel platforms.

A process signal is no interrupt at all, these are two different things.

An "interrupt" is something (in fact a signal) to the processor, usually issued by an "interrupt controller". It makes the processor get out of its current queue, enter another queue and - after finishing it - either return into the old queue or not.

A "signal" (in the sense of UNIX process signals, like SIGINT, etc.) are merely raised flags in the process accounting/scheduling part of the kernel.

To explain on your own example: when a user presses "CTL-C", a keyboard interrupt is issued, because UNIX, as a midrange system, runs usually on interrupt-driven systems (although not necessarily, like z/Linux, which runs on systems not entirely interrupt-driven, aka IBM mainframes). With PCs this is a BIOS interrupt (09 - keyboard), which will be passed to the keyboard driver. This driver will make sense of all the various make- and break-codes issued by the [8602- or similar]-microcontroller and figure out that the user pressed CTL-C (i am following the Intel-architecture here as it seems to be the one you are most familiar with, other systems might work differently but the principle remains the same). The kernel, learning about the user pressed CTL-C raises some flags in its process scheduling/job control part and the next time the process is passed a CPU the process will "know" that a SIGINT signal was sent. Now the process can decide if to handle it or ignore it.

I hope this helps.

bakunin
These 2 Users Gave Thanks to bakunin For This Post:
# 3  
Old 06-02-2015
Thanks for your answer.

Raising flags in a process structure was the idea I had about signal posting. It is this "cross-processor interrupt" thing what made me doubt. I've been looking for information about this, and it seems to be Solaris related. This is a quote from the Solaris Internals book:

Quote:
Interprocessor interrupts
The delivery of a signal may require interrupting a thread on another processor
However, I still don't know why such a signal delivery requires interrupting the processor the process is running in. Why can't those flags be simply raised for this process?
# 4  
Old 06-02-2015
These flags don't just sit there, they tell the kernel what to do. Setting one may mean the kernel has to take some action to accomplish what it's supposed to do.

This discussion is now crossing three different meanings of 'interrupt', by the by.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A question about signals in Unix

Whats a signal 0. An exhaustive search on signals landed me nowhere. Is it possible to do something like this trap "echo $var" 0. If so what signal does this trap catch ? (2 Replies)
Discussion started by: kinny
2 Replies

2. UNIX for Dummies Questions & Answers

about concept of Interrupts.

Hi all, I am new here ,i want to know about interrupts in detail.What r Interrupts .how they r handeled. Thanx in adavnce. (1 Reply)
Discussion started by: vishwasrao
1 Replies

3. Linux

How to interrupts work queue with signals

Hi masters, I am doing a project to regulate network bandwidth. I am using workqueue to implement packets management (I uses kernel threads inside each of these work queue) , netfilter hooks to implement packet catcher . All my modules individually works fine . But when I run my workqueues,... (1 Reply)
Discussion started by: iamjayanth
1 Replies

4. UNIX for Dummies Questions & Answers

Traps and Interrupts

Well, I don't know where exactly to ask this doubt so I'm asking in the newbie section. I was reading about traps and interrupts when I thought of traps as something that cease the control of the OS from the user and interrupts that cease the control yet provide support for multitasking. Am I right... (3 Replies)
Discussion started by: Legend986
3 Replies

5. UNIX for Advanced & Expert Users

Interrupts problems

Hi, My machine is a Unixware 7.1.3 is a files server, and I had never problem with that machine, but since two days, the machine presents slows problems, i think that the problem is te device interrupts, I had checked all and I dont found it any problem. Any idea? Thanks, (sorry my... (2 Replies)
Discussion started by: By_Jam
2 Replies

6. UNIX for Dummies Questions & Answers

catching interrupts

hey i have been facing a problem,can you tell me if we can catch ctrl d in unix i have tried and sucessfully catched and disabled ctrl-c and ctrl -z but am not sure if we can do the same for CTRL-D, so got any clue mail on he forum or ...i mean c programming in Unix thats what i am working on (1 Reply)
Discussion started by: toughguy2handle
1 Replies

7. Filesystems, Disks and Memory

Does unix use interrupts?

I'm a freshman here and I have a simple question. Does unix use interrupts which is like Dos? Are they the same? Thx.:cool: (6 Replies)
Discussion started by: Frank_M
6 Replies

8. Programming

Signals in Unix Solaris

I am doing a project to stimulate the scheduing policy of an OS under Unix Solaris. Its something like that: A process, say A will communicate to another process, which is the OS, and then execute the system call, pause(); The stimulated OS will then have to use sigsend(); to send a... (1 Reply)
Discussion started by: heljy
1 Replies

9. Programming

Unix/Linux Newbie(ish) Question - IPC/Signals

:) Hello, i have been given the following code to help me learn how to use signals, it won't compile. The problem maybe because this was written for use in Unix and i am trying to compile in Linux. The error i get says that SIGPIPE and SIG_IGN are undeclared. I think that these are defined... (2 Replies)
Discussion started by: theultimatechuf
2 Replies
Login or Register to Ask a Question