Reentrancy (computing) - Background

Background

Reentrancy is not the same thing as idempotence, in which the function may be called more than once yet generate exactly the same output as if it had only been called once. Generally speaking, a function produces output data based on some input data (though both are optional, in general). Shared data could be accessed by anybody at any time. If data can be changed by anybody (and nobody keeps track of those changes) then there is no guarantee for those who share a datum whether that datum is the same as at any time before. Idempotence implies reentrancy, but the converse is not necessarily true.

Data has a characteristic called a scope. Data is either global – outside the scope of any function and with an indefinite extent – or local – created each time a function is called and destroyed upon exit.

Local data are not shared by any, re-entering or not, routines; therefore, they do not affect re-entrance. Global data are either shared by any function (global variables) or shared by all functions of the same name (called static variables); therefore, they can affect re-entrance.

Reentrancy is distinct from, but closely related to, thread-safety. A function can be thread-safe and still not reentrant. For example, a function could be wrapped all around with a mutex (which avoids problems in multithreading environments), but if that function is used in an interrupt service routine, it could starve waiting for the first execution to release the mutex. The key for avoiding confusion is that reentrant refers to only one thread executing. It is a concept from the time when no multitasking operating systems existed.

Read more about this topic:  Reentrancy (computing)

Famous quotes containing the word background:

    Pilate with his question “What is truth?” is gladly trotted out these days as an advocate of Christ, so as to arouse the suspicion that everything known and knowable is an illusion and to erect the cross upon that gruesome background of the impossibility of knowledge.
    Friedrich Nietzsche (1844–1900)

    Silence is the universal refuge, the sequel to all dull discourses and all foolish acts, a balm to our every chagrin, as welcome after satiety as after disappointment; that background which the painter may not daub, be he master or bungler, and which, however awkward a figure we may have made in the foreground, remains ever our inviolable asylum, where no indignity can assail, no personality can disturb us.
    Henry David Thoreau (1817–1862)

    ... every experience in life enriches one’s background and should teach valuable lessons.
    Mary Barnett Gilson (1877–?)