I play with Go to understand its features and syntax. I made a simple producer-consumer program with parallel go functions and a priority buffer in the middle. One manufacturer creates tasks with a certain priority and sends them to the buffer using the channel. A set of consumers will request a task when it is idle, receives it, and consumes. The intermediate buffer will store a set of tasks in the priority queue buffer, therefore, tasks with the highest priority are performed first. The program also prints the activity of the garbage collector (how many times it was called and how long it took to collect the garbage).
I run it on a raspberry Pi using Go 1.1.
The software seems to be working fine, but I found that at the SO level, htop shows that there are 4 processes with the same memory usage, and the total CPU usage is more than 100% (Raspberry Pi has only one so I suppose this associated with threads / processes). In addition, the system load is about 7% of the processor, I believe, due to the constant context switching at the OS level. The GOMAXPROCS environment variable is set to 1 or not set.
Do you know why Go uses more than one OS process?
The code can be found here: http://pastebin.com/HJUq6sab
Thanks!
EDIT:
htop seems to show easy processes in the system. Go starts several such easy processes (they differ from goroutines threads), therefore when using htop several processes are shown, and ps or top will show only one, as it should be.
source share