reentrancy

Making existing ANSI C code threadsafe and re-entrant

人走茶凉 提交于 2019-12-23 03:23:44
问题 I am working on an old legacy ANSI C system, which is littered with a lot of global variables. I am part of a team refactoring the existing codebase, to make the code re-entrant and threadsafe. I found useful material on writing thread safe and re-entrant ANSI C code here. Based on my (admittedly non-perfect) understanding, I have come up with a proposal on how to proceed - but I have already come up with some issues that need addressing, and decided it best to come in here to find out the

Reentrancy was detected

左心房为你撑大大i 提交于 2019-12-22 14:41:03
问题 I'm getting "Reentrancy was detected" MDA error while setting a webbrowser control's properties. This only happens if I call "SetWindowsHookEx" to hook some dials within the same thread. Normally this hooking code works fine but it doesn't play nice with Webbrowser Control. When I ignore the exception code works fine, at least look like fine but obviously I'm a bit worried. Is there any idea why exactly this error is happening and how to resolve the problem. I've seen this article in MSDN -

Reentrancy in JavaScript

女生的网名这么多〃 提交于 2019-12-22 03:47:14
问题 I would like to improve my understanding of the word reentrant. Is this function reentrant? function* foo() { yield 1; yield 2; } And this one? function foo() { return 1; } And this one? var x = 0; function foo() { return x++; } And this one? function foo() { setTimeout(foo, 1000); } 回答1: A reentrent function is a function whose execution can be resumed: In computing, a computer program or subroutine is called reentrant if it can be interrupted in the middle of its execution and then safely

Is the Scala compiler reentrant?

孤人 提交于 2019-12-22 01:44:59
问题 For a multi-player programming game, I'm working on a background compilation server for Scala that supports compilation of multiple, independent source trees submitted by the players. I succeeded in running fast, sequential compilations without reloading the compiler by instantiating the Global compiler object via val compilerGlobal = new Global(settings, reporter) and then running individual compile jobs via val run = new compilerGlobal.Run run.compile(sourceFilePathList) I would now ideally

Is C++'s new operator reentrant (or async-safe)?

折月煮酒 提交于 2019-12-21 04:12:16
问题 The background is in this question of mine. Put shortly, I have to fork in a multithreaded C++ program, so I'd like to figure out how much I can do when restricted to reentrant functions only, and one of the most essential things is dynamic memory. So, malloc is known to be non-reentrant. But what about C++'s new ? I googled for that with not many relevant results (mostly due to the difficulty to hit the correct "new"), but there is at least one claim that new is reentrant. There is also a

Does SemaphoreSlim (.NET) prevent same thread from entering block?

自古美人都是妖i 提交于 2019-12-20 12:04:13
问题 I have read the docs for SemaphoreSlim SemaphoreSlim MSDN which indicates that the SemaphoreSlim will limit a section of code to be run by only 1 thread at a time if you configure it as: SemaphoreSlim _semaphoreSlim = new SemaphoreSlim(1, 1); However, it doesn't indicate if it stops the same thread from accessing that code. This comes up with async and await. If one uses await in a method, control leaves that method and returns when whatever task or thread has completed. In my example, I use

Mixing synchronized() with ReentrantLock.lock()

十年热恋 提交于 2019-12-20 11:59:05
问题 In Java, do ReentrantLock.lock() and ReetrantLock.unlock() use the same locking mechanism as synchronized() ? My guess is "No," but I'm hoping to be wrong. Example: Imagine that Thread 1 and Thread 2 both have access to: ReentrantLock lock = new ReentrantLock(); Thread 1 runs: synchronized (lock) { // blah } Thread 2 runs: lock.lock(); try { // blah } finally { lock.unlock(); } Assume Thread 1 reaches its part first, then Thread 2 before Thread 1 is finished: will Thread 2 wait for Thread 1

What is a re-entrant parser?

蓝咒 提交于 2019-12-20 10:37:49
问题 Can someone explain this to me? In particular the difference between: http://github.com/whymirror/greg and http://piumarta.com/software/peg/ The former being a re-entrant version of the later. 回答1: At its simplest a re-entrant parser doesn't use global variables and thus can have multiple instances active at the same time (not necessarily related to threading, but this is the main use case I suspect). In more complex use cases, however, you can have a parser that parses, in effect, multiple

Writing re-entrant lexer with Flex

安稳与你 提交于 2019-12-19 06:59:08
问题 I'm newbie to flex. I'm trying to write a simple re-entrant lexer/scanner with flex. The lexer definition goes below. I get stuck with compilation errors as shown below (yyg issue): reentrant.l: /* Definitions */ digit [0-9] letter [a-zA-Z] alphanum [a-zA-Z0-9] identifier [a-zA-Z_][a-zA-Z0-9_]+ integer [0-9]+ natural [0-9]*[1-9][0-9]* decimal ([0-9]+\.|\.[0-9]+|[0-9]+\.[0-9]+) %{ #include <stdio.h> #define ECHO fwrite(yytext, yyleng, 1, yyout) int totalNums = 0; %} %option reentrant %option

What is the difference between Lock and RLock

会有一股神秘感。 提交于 2019-12-18 10:07:53
问题 From the docs: threading.RLock() -- A factory function that returns a new reentrant lock object. A reentrant lock must be released by the thread that acquired it. Once a thread has acquired a reentrant lock, the same thread may acquire it again without blocking; the thread must release it once for each time it has acquired it. I am not sure why do we need this? what's the difference between Rlock and Lock ? 回答1: The main difference is that a Lock can only be acquired once. It cannot be