From owner-freebsd-current Fri Sep 19 14:04:50 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id OAA08580 for current-outgoing; Fri, 19 Sep 1997 14:04:50 -0700 (PDT) Received: from ns.mt.sri.com (SRI-56K-FR.mt.net [206.127.65.42]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id OAA08565; Fri, 19 Sep 1997 14:04:41 -0700 (PDT) Received: from rocky.mt.sri.com (rocky.mt.sri.com [206.127.76.100]) by ns.mt.sri.com (8.8.7/8.8.7) with ESMTP id PAA19303; Fri, 19 Sep 1997 15:04:34 -0600 (MDT) Received: (from nate@localhost) by rocky.mt.sri.com (8.7.5/8.7.3) id PAA20740; Fri, 19 Sep 1997 15:04:29 -0600 (MDT) Date: Fri, 19 Sep 1997 15:04:29 -0600 (MDT) Message-Id: <199709192104.PAA20740@rocky.mt.sri.com> From: Nate Williams MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Terry Lambert Cc: toor@dyson.iquest.net (John S. Dyson), nate@mt.sri.com, dyson@freebsd.org, karpen@ocean.campus.luth.se, current@freebsd.org Subject: Re: FYI: regarding our rfork(2) In-Reply-To: <199709192027.NAA01303@usr03.primenet.com> References: <199709191848.NAA02645@dyson.iquest.net> <199709192027.NAA01303@usr03.primenet.com> X-Mailer: VM 6.29 under 19.15 XEmacs Lucid Sender: owner-freebsd-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > The problem is that I may pass auto variables between threads: Then you have problems. > /* one of many threads with work to be done*/ > thread1() > { > struct req my_request; > > my_request.x = ...; > my_request.y = ...; > > do_requeust( &my_request); > > ... > } > > /* block calling thread until request completed*/ > do_request( struct req *preq) > { > ... > enqueue( preq); > ... > while( preq->status != REQ_COMPLETE) > YIELD; > } > > > /* lives only to service requests*/ > thread2() > { > struct req *preq; > > for(;;) { > /* spin to get next work item*/ > while( ( preq = dequeue()) == NULL) > YIELD; > > /* service work item*/ > ... > > /* mark work item completed*/ > preq->status = REQ_COMPLETE; > } > } I would argue that this program has many problems, waiting to happen that could be partially avoided by not using the stack. But, as Sean already pointed out to me many times, "that's the way things work in C, and we need to be backwards compatible". Why not allocate your struct req from the heap, which avoids someone reading/writing bogus data on your stack, thus corrupting it. Then again, I guess you could argue that *IFF* your stack gets corrupted, you'll know you're over-writing memory a heck of a lot quicker. :) In any case, I'm convinced that it's necessary in order to fully support C-Threads. Nate