[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trying to use cthread_fork() in the right way
From: |
Andre Caldas |
Subject: |
Re: Trying to use cthread_fork() in the right way |
Date: |
Fri, 25 Mar 2005 10:22:35 +0900 |
User-agent: |
Debian Thunderbird 1.0 (X11/20050116) |
Hello!
I didn't really started hacking the Hurd, so I may be talking really
silly here!
cthread_detach (cthread_fork (function_name, (void *) port_name));
>
but with this structure, is clear that there gonna be problems for tell that the
sent integer is s and the received is r. I was wasting time trying some bad ideas,
What structure? I don't see the problem here! You sent an integer whose
value is contained in s, and is trying to "receive" it's value in r.
Is port_name a pointer? Or an integer? How are you "uncasting" it?
If it is a pointer, then you need to keep the structure it points to
valid during the call.
but the code don't do what i want.
What code?
Maybe the the port destination
can't be used by the two threads, for a rights problem, i don't know, i'm
trying to learn.
As far as I know, the port thing is designed to work with threads.
If yes, if is possible to get that one thread do the sending of the integer and another
thread take this integer from the destination port.... how is the form (in generic) to
use cthread_fork() for adapt it to this case?.
I think what you said you did is OK. Maybe you are not doing exactly
what you think you are. The full code would help...
Maybe the previous structure of the program, with two separate functions for send and
receive and two diferents variables (s for "what" is sent and r for "what" is received)
do more dificult the adaptation to a threads case.
There is no problem with that. If you require "s" and "r" to be the same
thing, there is no point in "sending" and "receiving"! You could just
read "s"!! By the way, when you call your "send" function, only the
*value* stored in "s" is passed to it. The function is probably not
aware of any "s", anyway.
Andre Caldas.