From: Giacomo Tesio <giacomo@tesio.it>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] Privalloc(2) and rfork(RFPROC|RFMEM) (was: a pair nec bugs)
Date: Sat, 5 Sep 2015 20:42:41 +0200 [thread overview]
Message-ID: <CAHL7psHm+TE5PvWMP6XgQ5a=5C-c4xjGUN_G112oVPXp6g42pw@mail.gmail.com> (raw)
In-Reply-To: <b8520b52739689047e9d0543ae0a87c6@brasstown.quanstro.net>
[-- Attachment #1: Type: text/plain, Size: 1253 bytes --]
Nice example thanks.
May be my problem is that p is global in my case?
Giacomo
Il 05/Set/2015 18:50, "erik quanstrom" <quanstro@quanstro.net> ha scritto:
> 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("");
> }
>
>
[-- Attachment #2: Type: text/html, Size: 1860 bytes --]
next prev parent reply other threads:[~2015-09-05 18:42 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
2015-09-05 18:42 ` Giacomo Tesio [this message]
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='CAHL7psHm+TE5PvWMP6XgQ5a=5C-c4xjGUN_G112oVPXp6g42pw@mail.gmail.com' \
--to=giacomo@tesio.it \
--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).