On Wed, 7 Apr 2004, [gb2312] Lei Jin wrote:
Thank you for your detail explanation.
ACK. First of all, there's no need to CC me, I read dillo-dev!
I am still confused. Would you provide an example such as the situation of the two threads doing network job(what happens when using threads and mutexes and when using CCC chain)? Maybe it will help to understand.
When using threads and mutexes (pthreads), thread scheduling is done by a third thread or by the kernel (depends upon the implementation), and it is preemptive. Now, the address space may be shared, so the need for mutexes arise, and because of both reasons, performance is degraded. Using a pseudo-thread (CCC thread), doesn't require scheduling by an external process or by the kernel. All is done in the same process, but there's no preemption. (If you ever have heard that unthreaded servers are faster than threaded counterparts, you'll find the same reasons behind.) Now, since CCC-threads are not preemtive, Dillo also makes use of pthreads when it needs this ability (for instance for DNS resolving). As all the CCC-threads run in the same process, it's easy to sync with pthreads with a polling wait and an event. Cheers Jorge.-