Using system calls to create/context switch threads in assembly code
Hi all,
I am writing a compiler for a simple concurrent programming language. The compiler has to produce assembly code for Intel-32 architectures.
One of the major issue for code generation is how to create multithreaded assembly code. Linux provides system calls for creating threads, clone(,,,,). However, it seems there is no system call for doing context swiching for threads (is that so?). Also, our compiler has to deal with synchronizations among threads, so there should be a ready-queue that holds all ready-to-run threads and several waiting-queue. In order to do context swtiching, the compiler must be able to access each thread's CPU registers values (more specificly, the running thread's CPU register values need to be saved with the thread during context switching, so an array representing the CPU registers is needed to contruct a thread). I am not sure all of those are supported by the threads created with system calls.
Is it possible to construct a multi-threaded assembly program without making Linux system calls? Odd question, isn't? I do hope there is a solution.
Anyone has some suggestions?
Thanks
tony
|