Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do signals interact with sequence points?

The C89 standard states:

At sequence points volatile objects are stable in the sense that previous
evaluations are complete and subsequent evaluations have not yet occurred.

The C89 standard also states:

When the processing of the abstract machine is interrupted by receipt of a
signal, only the values of objects as of the previous sequence point may be
relied on.

These requirements leave me confused, because I can't imagine how they would actually be implemented. I only have a rudimentary understanding of x86-64 assembler, but here's what is running through my head. Let's say that we have a volatile struct, and it's many kilobytes large. If you copy an existing struct into this volatile struct in C, then the resulting machine code might be very large. Now, let's say that this large amount of machine code is executing, and some shell on the system executes the "kill" command on the process, causing the raising of some signal. My understanding (or rather my guess) is that the process would be interrupted in mid-copy, causing the requirement on volatile to be broken, and causing the struct be malformed from the perspective of any signal handler.

Obviously things don't actually work like this, but then how do they actually work? For the sake of argument feel free to assume that the platform is x86-64 or x86 Linux, Windows, OS X, or some other common UNIX.

like image 226
fieldtensor Avatar asked Jul 26 '14 20:07

fieldtensor


People also ask

What do signaling proteins interact with?

In addition to their enzymatic domains, signalling proteins contain binding domains (SH2, SH3, PTB, PH, etc.), which allow interactions with other proteins. Adaptor proteins contain binding domains (but not enzymatic domains), hence bringing different signalling proteins in close proximity.

How do cells recognize and respond to signals?

How Do Cells Recognize Signals? Cells have proteins called receptors that bind to signaling molecules and initiate a physiological response. Different receptors are specific for different molecules.

How are signals relayed between cells?

Cells typically communicate using chemical signals. These chemical signals, which are proteins or other molecules produced by a sending cell, are often secreted from the cell and released into the extracellular space. There, they can float – like messages in a bottle – over to neighboring cells.

What is the pathway of a signal?

Describes a series of chemical reactions in which a group of molecules in a cell work together to control a cell function, such as cell division or cell death.


1 Answers

At sequence points volatile objects are stable in the sense that previous evaluations are complete and subsequent evaluations have not yet occurred.

This wouldn't be violated, since the interruption is not a sequence point. This rule only describes what happens "at sequence points". If we are interrupted after sequence point A and before sequence point B completes, we aren't "at" sequence point A or sequence point B.

When the processing of the abstract machine is interrupted by receipt of a signal, only the values of objects as of the previous sequence point may be relied on.

This wouldn't be violated. If we are interrupted between sequence points A and B, say in mid copy, all the changes made at sequence point A can be relied on. They're done.

Being able to relying on a previous modification doesn't mean that you won't see any effects of a subsequent modification. Values are stable until some future bit of code can modify them.

So the obvious implementation doesn't violate either of the requirements.

like image 85
David Schwartz Avatar answered Nov 01 '22 07:11

David Schwartz