From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] Privalloc(2) and rfork(RFPROC|RFMEM) (was: a pair nec bugs)
Date: Sat, 5 Sep 2015 09:41:02 -0700 [thread overview]
Message-ID: <b8520b52739689047e9d0543ae0a87c6@brasstown.quanstro.net> (raw)
In-Reply-To: <c5074e079951b5f122ddc9cf2fa08134@brasstown.quanstro.net>
by the way, the following program runs without asserting for me
with or without the waits.
- erik
---
#include <u.h>
#include <libc.h>
void
task(void **p)
{
assert(*p == nil);
*p = (void*)(uintptr)getpid();
}
void
spawn(void (*t)(void**), void **p)
{
int pid;
switch(pid = rfork(RFMEM|RFPROC)){
case -1:
sysfatal("spawn: rfork: %r");
case 0:
t(p);
exits("");
default:
USED(pid);
return;
}
}
void
main(void)
{
int i, k;
void **p;
Waitmsg *w;
p = privalloc();
k = 0;
for(i = 0; i < 1024; i++){
spawn(task, p);
for(k++; k > 16; k--){
if((w = wait()) == nil)
break;
free(w);
}
}
exits("");
}
next prev parent reply other threads:[~2015-09-05 16:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-05 14:03 Giacomo Tesio
2015-09-05 14:11 ` Giacomo Tesio
2015-09-05 15:27 ` erik quanstrom
2015-09-05 16:41 ` erik quanstrom [this message]
2015-09-05 18:42 ` Giacomo Tesio
2015-09-05 18:47 ` erik quanstrom
2015-09-05 23:03 ` Giacomo Tesio
2015-09-05 18:56 ` cinap_lenrek
2015-09-05 22:45 ` Charles Forsyth
2015-09-05 23:38 ` cinap_lenrek
2015-09-06 13:14 ` erik quanstrom
2015-09-06 14:12 ` Charles Forsyth
2015-09-06 15:02 ` erik quanstrom
2015-09-06 20:21 ` Charles Forsyth
2015-09-07 0:30 ` erik quanstrom
2015-09-07 9:38 ` Charles Forsyth
2015-09-07 11:59 ` Charles Forsyth
2015-09-06 18:21 ` cinap_lenrek
2015-09-06 20:27 ` Charles Forsyth
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=b8520b52739689047e9d0543ae0a87c6@brasstown.quanstro.net \
--to=quanstro@quanstro.net \
--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).