[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Some questions about concurrency (mostly)
From: |
Fredrik Appelberg |
Subject: |
Some questions about concurrency (mostly) |
Date: |
Thu, 05 Nov 2020 23:22:09 +0100 |
Hi all,
I learned Scheme back in my university days, but that was mostly
computer sciency, SICP stuff. Now I'm trying to get actual, practical
work done, and have to read up on threads, I/O and all that jazz. So I
have some newbie questions:
1. Are there any problems with creating a condition (as in exception,
not srfi-18 condition variable) in one thread and raising it in one
or more other threads?
2. In my application I'm running a thread that reads from a TCP port and
dispatches frames back to the main thread using a mailbox (from the
mailbox egg). I'm also running a separate thread that sends a
heartbeat frame back over the TCP connecion every 30s. This works
fine, but I've noticed that after a while (this seems to happen
consistently after the first heartbeat has been sent) I cannot press
Ctrl-C in the terminal to stop the application. However, as soon as
the dispatcher thread reads an incoming frame, the process is
interrupted. I assume this has something to do with blocking threads?
Is there something I can do about it?
3. I'm new to dynamic-wind. If I wanted to create a general form for
executing a thunk protected by a mutex, would this be a good idea?
(define (with-lock mutex thunk)
(dynamic-wind
(lambda () (mutex-lock! mutex))
thunk
(lambda () (mutex-unlock! mutex)))))
I read somewhere that the before- and after-guards might execute
multiple times, but then again I'm not really sure under what
circumstances so I might be way off.
4. The srfi-18 thread scheduler seems to behave slightly differently
when running compiled code and in csi. Is that correct?
Cheers,
-- Fredrik
- Some questions about concurrency (mostly),
Fredrik Appelberg <=