Overclock.net banner
1 - 4 of 4 Posts

·
Premium Member
Joined
·
6,045 Posts
Discussion Starter · #1 ·
[If nobody knows the answer to my question, a link to another forum I might have better luck on what be fantastic
]

I am watching a set of video lectures on basic operating system concepts, and I have come to a point where I have become somewhat lost. The code is meant to demonstrate how producer/consumer applications with a buffer works (like computer to a printer) using coend and cobegin structure. The values presented are as follows:

Type item= ; - I think this is meant to be undefined
var buffer= array of [o....n-1] of type item -equals n-1 because the producer process is always consuming at least one type item I think
in, out= 0....n-1

nextp, next c: item;
in=0
out=0

-------

code for producer:

cobegin

producer: begin
repeat
...
produce an item in nextp;
...
while (in+1)mod n=out do skip;
buffer [in]= nextp;
in= (n+1) mode n;
until false
end

consumer: begin
repeat
while in=out do skip
next c=buffer [out]
out= (out+1)
...
consumer item in next;
...
until false
end
coend

I understand the n equals the number of item places in the buffer, and the var buffer is n-1 because the consumer process is always consuming at least one type item. However, when you start adding equations I find myself just completely lost. Could anybody shed some light on this for me please?
 

·
Fan Man
Joined
·
1,291 Posts
Cobegin and coend are used to create parallel processes. That code seems to contain a series of errors and I believe this is the reason you are not understanding what it does.

Make sure you check the text after you do copy-paste next time
 

·
Premium Member
Joined
·
6,045 Posts
Discussion Starter · #3 ·
This is what I took down as notes... I believe that errors were included on purpose to demonstrate a point, as the professor in the lecture said that there were two flaws with the code, but I really coudn't understand what was happening with the base code to begin with so I posted this.

I know what cobegin and coend are, but I don't know exactly what is all happening in between.
 

·
Premium Member
Joined
·
13,477 Posts
What language is that? It looks kind of like Pascal. I haven't seen that in almost 20 years.
 
1 - 4 of 4 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top