From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <28ff9005991e4d1456712876624cc583@gmx.de> To: 9fans@9fans.net Date: Sat, 9 Jan 2010 05:52:53 +0100 From: cinap_lenrek@gmx.de In-Reply-To: <20100108094014.GA16595@machine> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-gbwoetkrmiepgbnppwbzfgcgro" Subject: Re: [9fans] libthread API Topicbox-Message-UUID: bb32bcc2-ead5-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-gbwoetkrmiepgbnppwbzfgcgro Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit 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 --upas-gbwoetkrmiepgbnppwbzfgcgro Content-Type: message/rfc822 Content-Disposition: inline Return-Path: <9fans-bounces+cinap_lenrek=gmx.de@9fans.net> X-Flags: 0000 Delivered-To: GMX delivery to cinap_lenrek@gmx.de Received: (qmail invoked by alias); 08 Jan 2010 22:59:17 -0000 Received: from gouda.swtch.com (EHLO gouda.swtch.com) [67.207.142.3] by mx0.gmx.net (mx075) with SMTP; 08 Jan 2010 23:59:17 +0100 Received: from localhost ([127.0.0.1] helo=gouda.swtch.com) by gouda.swtch.com with esmtp (Exim 4.69) (envelope-from <9fans-bounces@9fans.net>) id 1NTNjZ-0004KW-Fq; Fri, 08 Jan 2010 22:55:09 +0000 Received: from karen.lavabit.com ([72.249.41.33]) by gouda.swtch.com with esmtp (Exim 4.69) (envelope-from ) id 1NTNjX-0004KR-Ht for 9fans@9fans.net; Fri, 08 Jan 2010 22:55:07 +0000 Received: from e.earth.lavabit.com (e.earth.lavabit.com [192.168.111.14]) by karen.lavabit.com (Postfix) with ESMTP id 4B37A11B881 for <9fans@9fans.net>; Fri, 8 Jan 2010 16:55:06 -0600 (CST) Received: from localhost (95.72.156.66) by lavabit.com with ESMTP id DL98OTENO6VR for <9fans@9fans.net>; Fri, 08 Jan 2010 16:55:06 -0600 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lavabit; d=lavabit.com; b=GWjVZTmFJmMWexgsfOxH/WZSZeemeCZMHyKKJd5yXsdLu/LTG78v/bEzEc3s3CijFM4nA8UgWywLY5ME8GeGLPuvgHUc81aTl5QIGjTiu/a2Z3+520+7HC/xHjEnCBLDsiFghFi23Wle0t42mhb3DNokfr+GToMAKgqEePxwhPI=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition; Date: Fri, 8 Jan 2010 12:40:14 +0300 From: anonymous To: 9fans@9fans.net Message-ID: <20100108094014.GA16595@machine> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [9fans] libthread API X-BeenThere: 9fans@9fans.net X-Mailman-Version: 2.1.10 Precedence: list Reply-To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> List-Id: Fans of the OS Plan 9 from Bell Labs <9fans.9fans.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: 9fans-bounces@9fans.net Errors-To: 9fans-bounces+cinap_lenrek=gmx.de@9fans.net X-GMX-Antivirus: 0 (no virus found) X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=5D7Q89H36p5Oer5+B3tmVe929Xp50yuJTdf0JQgOXwaKpCK3n4ZJpmNV9fvOG+MpnacmH Zp2aq/FBNs5mRc1nJ1xtHsYpmN1pSS+ZGNhx6WQuXLEwLmOFaUScQ1+ON2QzOr3C+ox/NO/eU18X FRyeWf2QEuMWCCXV1; X-GMX-UID: /I90f0dhf2I/fKguz2xoIltwdWxlcxbt 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? --upas-gbwoetkrmiepgbnppwbzfgcgro--