chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Thread safe hash tables?


From: Thomas Chust
Subject: Re: [Chicken-users] Thread safe hash tables?
Date: Sat, 4 Mar 2006 20:07:05 +0000 (GMT)

On Sat, 4 Mar 2006, KonLovett wrote:

On Mar 2, 2006, at 4:37 AM, Thomas Chust wrote:

Hello,

just a small question: Are CHICKEN's hash tables threadsafe by design or do I have to surround all hash table accesses in multithreaded applications by a mutex-lock! / mutex-unlock! pair?

FWIW my reading of the source is 1) No & 2) Yes. You could surround access w/ disable/enable interrupts, since that would inhibit a context switch by the schedular during the access. But I think creating a "thread-safe" wrapper around your shared data-structure, as you suggest, is the best.
[...]

Hello,

so you think I can mess up the internal data structure of a hash table if I access it concurrently from two threads? That's nasty. I'll have to put a bazillion of those
  (dynamic-wind
      (lambda () (mutex-lock! some-hash-mtx))
      (lambda () (do-something-to (mutex-specifix some-hash-mtx)))
      (lambda () (mutex-unlock! some-hash-mtx)))
blocks into my code. But thank you for telling me, because after some tests I thought the hash tables *were* thread safe.

cu,
Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]