11 func random_entre (begin, end int64) int64 {
12 random_byte := make([]byte, 1)
13 rand.Read(random_byte)
14 return int64(random_byte[0]) % (end - begin + 1) + begin
17 func random_sleep () {
18 time.Sleep(random_entre(0, MAX_SLEEP_TIME) * 10e7)
21 func signal (channel chan int) {
22 if len(channel) < cap(channel) || cap(channel) == 0 {
27 func wait (channel chan int) {
35 Println("produzindo:", i)
37 rear = (rear + 1) % BUFFER_SIZE
50 front = (front + 1) % BUFFER_SIZE
51 Println("\tconsumindo:", v)
59 const MAX_SLEEP_TIME = 5
63 mutex = make(chan int, 1);
72 buffer = make([]int, BUFFER_SIZE)
73 empty = make(chan int, BUFFER_SIZE);
74 full = make(chan int, BUFFER_SIZE)
75 for i := 0; i < BUFFER_SIZE; i++ {