9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: cinap_lenrek@gmx.de
To: 9fans@9fans.net
Subject: Re: [9fans] libthread API
Date: Sat,  9 Jan 2010 05:52:53 +0100	[thread overview]
Message-ID: <28ff9005991e4d1456712876624cc583@gmx.de> (raw)
In-Reply-To: <20100108094014.GA16595@machine>

[-- Attachment #1: Type: text/plain, Size: 642 bytes --]

the threads and procs that are created by libthread have ther stacks
malloc()ed, so one thread can allocate a structure or buffer on its
stack and pass a pointer to another thread or proc.  when you would do
a rfork(RFMEM) in a libthread program, the stacks would have been
shared by parent and child! libthread does some setjmp/longjmp magic to
switch the stack to the original plan9 stack segment to be able todo
a real rfork when spawning new procs.

also linux clone syscall takes a pointer to the routine running
in a new "thread" for a similar reason. they dont have the concept
of a always copy-on-write stack.

--
cinap

[-- Attachment #2: Type: message/rfc822, Size: 3291 bytes --]

From: anonymous <aim0shei@lavabit.com>
To: 9fans@9fans.net
Subject: [9fans] libthread API
Date: Fri, 8 Jan 2010 12:40:14 +0300
Message-ID: <20100108094014.GA16595@machine>

Why libthread has threadcreate instead of something like fork? With
threadcreate you should make struct to pass more than one argument and
pass a pointer to it.

I also see no problem with recieving different values for each thread.
Memory is shared, but return value is stored in register (accumulator
register for x86) which is not shared.

Maybe it was made for compatibility with Alef? In Alef it is possible
to return mulitply values, maybe they are stored in memory. But there
is rfork with RFMEM flag and it has no problem.

And by the way when libthread should be used and when rfork(RFMEM) is
better?

  parent reply	other threads:[~2010-01-09  4:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-08  9:40 anonymous
2010-01-09  4:29 ` Gorka Guardiola
2010-01-09  4:33   ` erik quanstrom
2010-01-09  4:52 ` cinap_lenrek [this message]
2010-01-09  5:33   ` anonymous
2010-01-09  5:50     ` cinap_lenrek
2010-01-09  5:55       ` Bruce Ellis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=28ff9005991e4d1456712876624cc583@gmx.de \
    --to=cinap_lenrek@gmx.de \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).