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:

    They were more than hostile. In the first place, I was a south Georgian and I was looked upon as a fiscal conservative, and the Atlanta newspapers quite erroneously, because they didn’t know anything about me or my background here in Plains, decided that I was also a racial conservative.
    Jimmy Carter (James Earl Carter, Jr.)

    I had many problems in my conduct of the office being contrasted with President Kennedy’s conduct in the office, with my manner of dealing with things and his manner, with my accent and his accent, with my background and his background. He was a great public hero, and anything I did that someone didn’t approve of, they would always feel that President Kennedy wouldn’t have done that.
    Lyndon Baines Johnson (1908–1973)

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