title: Go program launching several processes
body: <p>I'm playing with Go to understand its features and syntax. I've done a simple producer-consumer program with concurrent go functions, and a priority buffer in the middle. A single producer produces tasks with a certain priority and send them to a buffer using a channel. A set of consumers will ask for a task when idle, received it and consume it. The intermediate buffer will store a set of tasks in a priority queue buffer, so highest priority tasks are served first.  The program also prints the Garbage collector activity (how many times it was invoked and how many time it took to collect the garbage).</p>
  
  <p>I'm running it on a Raspberry Pi using Go 1.1. </p>
  
  <p>The software seems to work fine but I found that at SO level, htop shows that there are 4 processes running, with the same memory use, and the sum of the CPU use is over 100% (the Raspberry Pi only has one core so I suppose it has something to do with threads/processes). Also the system load is about 7% of the CPU, I suppose because of a constant context switching at OS level. The GOMAXPROCS environment variable is set to 1 or unset.</p>
  
  <p>Do you know why Go is using more than one OS process?</p>
  
  <p>Code can be found here: <a href="http://pastebin.com/HJUq6sab" rel="nofollow">http://pastebin.com/HJUq6sab</a></p>
  
  <p>Thank you!</p>
  
  <p><b>EDIT:</b></p>
  
  <p>It seems that <code>htop</code> shows the lightweight processes of the system. Go programs run several of these lightweight processes (they are different from the goroutines threads) so using <code>htop</code> shows several processes, while <code>ps</code>or <code>top</code> will show just one, as it should be.</p>