Hi Dhruv!

Dhruv Gami wrote:

Could you please elaborate on whatever u said ? i dont know about the others, but all this went over my head, and now im curious to know what was being talked about :)

Well ... I'll try to simplify
LWPs or as Supreet very correctly said ... clones on Linux ... are a way of implementing
schedulable executing enitites which are not processes but execute as a part of a process.
If you are thinking 'threads' then you are right :)


There are three types of scheduleable entities which can be created:
1. kernel threads : run in kernel space, created using the function kernel_thread.
The project I proposed doesn't touch this as of now, but if the need arises ...
we might have to use this function.


2. clones : run in user space, created using the clone() lib routine, which calls sys_clone()
function from inside the kernel. This is what I want to focus on. The advantage
being that individual functions can be scheduled independently.
( If you have objections with the word 'scheduled', I'll comply ... :) )


3. processes : run in user space, created using fork() lib routine, which calls sys_fork()
from inside the kernel. Not interested in processes directly.


A small summary:
fork() , clone() are library routines wrapped around sys_fork() and sys_clone() kernel
functions. Both these functions are written on top of do_fork() kernel function which
has argument 'clone_flags' besides two other related to the stack (and another one related
to context)
(I could go to lengths describing the entire stuff ... but wanna keep it simple)
So simply ... the fork() routine ... or the creation of an entire process is just a special
case of a clone() creation where the clone_flags force the clone to turn into a full
process. So basically, clones are available as/in-place-of LWPs, what needs to be
seen wethet a solution for C++ programmers can be found or not.


Now what I want to do is to have a set of classes written in C++ which allows us
to instantiate objects which execute functions independently ... as in concurrency.
i.e. to have a clone() call embedded in the class constructor or filtered elsewhere
but instantiation of object should result in a clone or thread.


The reason should be clear if you yourself try encapsulating fork() inside a
class, 'exec'ing and then go ahead and try implementing synchronization
also. Can be done ... no doubt. But would be a lot easier if it were done
using clone() and if all this were wrapped up neatly in C++ classes.
(I managed to implement ONE-MANY client-server skeleton using Semaphores
but ... it was done in C ... I can't imagine doing it in C++ ... OK ... it can be done
but if one is to implement code-reuseability ... he'll have to work real hard)


One of the solutions is infact wrapping up POSIX threads inside classes.
(But is that fun ? besides ... adding another library to be linked :( )

There are other solutions, but most of them state ...
"a set of C++ wrappers is under current developement"

I want to start by wrapping up clone() call itself and simplify the
stuff into classes.
(Again ... I request that someone knows of this thing being done
 already ... plz let me know ... I tried googling but results were as
 mentioned above)

So ... if there are more doubts ... plz write in ... that'll help me too.

Regards,
Gagan.


================================================ To unsubscribe, send email to [EMAIL PROTECTED] with unsubscribe in subject header. Check archives at http://www.mail-archive.com/ilugd%40wpaa.org



Reply via email to