[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] critical-section not in Chicken 3?
From: |
Elf |
Subject: |
Re: [Chicken-users] critical-section not in Chicken 3? |
Date: |
Tue, 5 Feb 2008 09:30:20 -0800 (PST) |
im pretty sure you need mutexes. its pretty easy though...
(define-macro (protect-section ml . body)
`(if (list? ,ml)
(let ((retval) (begin
(for-each (lambda (x) (mutex-lock! x #f #f) ,ml)
,@body)))
(for-each mutex-unlock! ,ml)
retval)
(let ((retval (begin
(mutex-lock! ,ml #f #f)
,@body)))
(mutex-unlock! ,ml)
retval)))
this should work for any number of mutexes passed into protect-section.
if you want an only-single-mutex case, define the mutex (lets call it mtx)
and then :
(define-macro (protect-section . body)
`(let ((retval (begin
(mutex-lock! mtx #f #f)
,@body)))
(mutex-unlock! mtx)
retval))
should work.
-elf
On Tue, 5 Feb 2008, Graham Fawcett wrote:
Hi folks,
I'm porting some old code that had a (critical-section) in it, to ensure
that a set of instructions was completed atomically with respect to the rest
of the program. But it looks like critical-section is no longer supported in
Chicken 3.
I could move to mutexes, but it will be a bit of a pain. Is there any way to
emulate (critical-section) in Chicken 3, or has the runtime changed so that
it's no longer possible?
Thanks,
Graham
- [Chicken-users] critical-section not in Chicken 3?, Graham Fawcett, 2008/02/05
- Re: [Chicken-users] critical-section not in Chicken 3?,
Elf <=
- Re: [Chicken-users] critical-section not in Chicken 3?, Graham Fawcett, 2008/02/05
- Re: [Chicken-users] critical-section not in Chicken 3?, Kon Lovett, 2008/02/05
- Re: [Chicken-users] critical-section not in Chicken 3?, Graham Fawcett, 2008/02/05
- Re: [Chicken-users] critical-section not in Chicken 3?, felix winkelmann, 2008/02/06
- Re: [Chicken-users] critical-section not in Chicken 3?, Ivan Raikov, 2008/02/06
- Re: [Chicken-users] critical-section not in Chicken 3?, Elf, 2008/02/06
- Re: [Chicken-users] critical-section not in Chicken 3?, Tobia Conforto, 2008/02/09
- Re: [Chicken-users] critical-section not in Chicken 3?, Elf, 2008/02/11
- Re: [Chicken-users] critical-section not in Chicken 3?, Elf, 2008/02/05
- Re: [Chicken-users] critical-section not in Chicken 3?, Kon Lovett, 2008/02/05