reentrancy

Why are malloc() and printf() said as non-reentrant?

偶尔善良 提交于 2019-11-27 00:09:35
In UNIX systems we know malloc() is a non-reentrant function (system call). Why is that? Similarly, printf() also is said to be non-reentrant; why? I know the definition of re-entrancy, but I wanted to know why it applies to these functions. What prevents them being guaranteed reentrant? malloc and printf usually use global structures, and employ lock-based synchronization internally. That's why they're not reentrant. The malloc function could either be thread-safe or thread-unsafe. Both are not reentrant: Malloc operates on a global heap, and it's possible that two different invocations of

Stopping timer in its callback method

佐手、 提交于 2019-11-26 22:44:06
问题 I have a System.Threading.Timer that calls its appropriate event handler (callback) every 10 ms . The method itself is not reentrant and can sometimes take way longer than 10 ms . Thus, I want to stop the timer during method execution. Code: private Timer _creatorTimer; // BackgroundWorker's work private void CreatorWork(object sender, DoWorkEventArgs e) { _creatorTimer = new Timer(CreatorLoop, null, 0, 10); // some other code that worker is doing while the timer is active // ... // ... }

Threadsafe vs re-entrant

孤者浪人 提交于 2019-11-26 14:53:32
Recently, I asked a question, with title as "Is malloc thread safe?" , and inside that I asked, "Is malloc re-entrant?" I was under the impression that all re-entrant are thread-safe. Is this assumption wrong? Re-entrant functions do not rely on global variables that are exposed in the C library headers .. take strtok() vs strtok_r() for example in C. Some functions need a place to store a 'work in progress' , re-entrant functions allow you to specify this pointer within the thread's own storage, not in a global. Since this storage is exclusive to the calling function, it can be interrupted

Threadsafe vs re-entrant

懵懂的女人 提交于 2019-11-26 04:05:11
问题 Recently, I asked a question, with title as \"Is malloc thread safe?\", and inside that I asked, \"Is malloc re-entrant?\" I was under the impression that all re-entrant are thread-safe. Is this assumption wrong? 回答1: Re-entrant functions do not rely on global variables that are exposed in the C library headers .. take strtok() vs strtok_r() for example in C. Some functions need a place to store a 'work in progress' , re-entrant functions allow you to specify this pointer within the thread's

Is process in VHDL reentrant?

[亡魂溺海] 提交于 2019-11-25 23:44:48
问题 Is it possible two or more sequential run for a process in VHDL ? What will happen if another event happen (on sensitivity signal list) while the sequential execution of a process is not completed ? Is it possible or my VHDL model in mind for process is completely wrong? 回答1: No event will ever occur while a process is running! When a process is woken by an event, it runs to completion ("end process") or an explicit "wait" statement, and goes to sleep. This takes, notionally, ZERO time. Which