[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trying to use cthread_fork() in the right way
From: |
Jose Luis Alarcon Sanchez |
Subject: |
Re: Trying to use cthread_fork() in the right way |
Date: |
Sat, 26 Mar 2005 18:48:34 +0000 |
El vie, 25-03-2005 a las 10:22 +0900, Andre Caldas escribió:
> 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.
Hi Andre!.
Thanks you, very much, for take interest in my question.
This program
http://www.nongnu.org/hurdextras/ipc_guide/code/bootstrap_ipc.c
works.
I only was trying to "introduce" the cthreads programming to it, but i
am afraid that my skills making new code are not too wide.
I know the message can be received through the same variable used for
send it, but i found "nice" this author's method for use two diferents
variables.
Thanks, anyway.
Regards.
Jose.
--
http://www.lordofunix.org
Not Registered GNU/Hurd User.
Registered BSD User 51101.
Registered Linux User #213309.
Memories..... You are talking about memories.
Rick Deckard. Blade Runner.