9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: ron minnich <rminnich@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] Fwd: plan9 go output faults on 9vx with rfork
Date: Wed, 19 Jan 2011 07:52:41 -0800	[thread overview]
Message-ID: <AANLkTimjMXA0riWGe=MiMxadrCyi-sTNp802w24Yc=Nj@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikUa1KF+8NP54BHicus++YbeZbD48E7z=1H0Y5V@mail.gmail.com>

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

Pavel sent me sieve, and it is up to 11083 on my 9vx on darwin. I
declare go on 9vx on darwin fixed.

Linux is next.

ron

[-- Attachment #2: sieve --]
[-- Type: application/octet-stream, Size: 130480 bytes --]

[-- Attachment #3: sieve.go --]
[-- Type: application/octet-stream, Size: 1027 bytes --]

// $G $F.go && $L $F.$A  # don't run it - goes forever

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import "runtime"

// Send the sequence 2, 3, 4, ... to channel 'ch'.
func Generate(ch chan<- int) {
	for i := 2; ; i++ {
		ch <- i // Send 'i' to channel 'ch'.
	}
}

// Copy the values from channel 'in' to channel 'out',
// removing those divisible by 'prime'.
func Filter(in <-chan int, out chan<- int, prime int) {
	for {
		i := <-in // Receive value of new variable 'i' from 'in'.
		if i%prime != 0 {
			out <- i // Send 'i' to channel 'out'.
		}
	}
}

// The prime sieve: Daisy-chain Filter processes together.
func Sieve() {
	ch := make(chan int) // Create a new channel.
	go Generate(ch)      // Start Generate() as a subprocess.
	for {
		prime := <-ch
		print(prime, "\n")
		ch1 := make(chan int)
		go Filter(ch, ch1, prime)
		ch = ch1
	}
}

func main() {
	runtime.GOMAXPROCS(4)
	Sieve()
}

       reply	other threads:[~2011-01-19 15:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AANLkTikJ3y5exFtTic+8dhUsUqeZBDmR=S-8VzKDK0GH@mail.gmail.com>
     [not found] ` <AANLkTink4CrELJfGf3W15caSYX8Se5ygsm_WeMRdCBz=@mail.gmail.com>
     [not found]   ` <AANLkTikUa1KF+8NP54BHicus++YbeZbD48E7z=1H0Y5V@mail.gmail.com>
2011-01-19 15:52     ` ron minnich [this message]
     [not found] <AANLkTinx9AiBN4=7knPEK8sKuuCUe+mhhNaP-yZzqVSS@mail.gmail.com>
     [not found] ` <AANLkTikf4cgk7hab5rLLFWyv-c-0XU6WPJW0Ahm4JehM@mail.gmail.com>
     [not found]   ` <AANLkTi=PdAFFDw=ps6DcR38xno_mNb8eGZRJGxL0VpQC@mail.gmail.com>
     [not found]     ` <AANLkTinDengSNpD6pEg_cF6xivxc3qU3=tQFW7Wyo769@mail.gmail.com>
     [not found]       ` <AANLkTiky+x0gBcr84_p0Mf9HKqGVoTFcyNrdofEMS9_a@mail.gmail.com>
2011-01-19  2:37         ` ron minnich

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='AANLkTimjMXA0riWGe=MiMxadrCyi-sTNp802w24Yc=Nj@mail.gmail.com' \
    --to=rminnich@gmail.com \
    --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).