[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: threads
From: Waldo Bastian <bastian () suse ! de>
Date: 1999-12-03 14:08:32
[Download RAW message or body]
On Fri, 03 Dec 1999, Dirk A. Mueller wrote:
> On Fre, 03 Dez 1999, Lubos Lunak wrote:
>
> > Well, Pth is cooperative multithreading library, and has exactly defined
> > context-switch points
>
> that's the problem. _cooperative_ multithreading is in no way better than
> the current QTimer solution. If one thread blocks, the whole app will hang.
Summary:
========
Its basically impossible to get pre-emptive multithreading reliable.
Cooperative multithreading is an option. The benefit is that it is much easier
to program a worker thread than QTimer beased state machine. The disadvanatge
is that calls like fopen() still block.
The other option is to use processes as we do with the io_slaves. The
disadvantage here is that it requires more memory and the IPC is somewhat
slower. The advantage is that a dying io_slave doen't crash your application.
Discussion:
=========
In theory you can do cooperative multithreading toghether with kernel-threads.
Whenever you are about to enter a possible-blocking system call, you use a
kernel-thread for this. This way you can make it that you keep the semantics of
cooperative-multithreading but you don't have the disadvantage of blocking on
system calls.
(A quick & dirty way to get this behaviour is to use kernel-threads and lock a
mutex all the time except for when you are about to enter a system call.)
Cheers,
Waldo
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic