Hi

When a switch from thread 1 to thread 2 is done, actually there do
occure two context switches. One from thread 1 to the scheduler and a
second from the scheduler to thread 2.

I wonder why the scheduler's algorithms aren't computed in the contexts
of the user threads so that one could switch from thread 1 to thread 2
directly. This would halve the number of context switches.

I managed to write a minimal thread library using the pth_uctx functions
following the above described strategy and it seems to work (on a Debian
GNU/Linux sarge, gcc-3.3)

The only case where one needs an extra context is when a thread is
quitting as one cannot destroy a context from within this context (can
you?).

For the case you want to have a look at this proof of concept:
http://copton.net/pth-fast.tar.gz

Is there a reason for the current implementation I don't see?

cu

-- 
Alexander Bernauer
______________________________________________________________________
GNU Portable Threads (Pth)            http://www.gnu.org/software/pth/
Development Site                      http://www.ossp.org/pkg/lib/pth/
Distribution Files                          ftp://ftp.gnu.org/gnu/pth/
Distribution Snapshots                 ftp://ftp.ossp.org/pkg/lib/pth/
User Support Mailing List                            pth-users@gnu.org
Automated List Manager (Majordomo)           [EMAIL PROTECTED]

Reply via email to