Skip to content

【Bug Report】Lecture 10 Semaphores II #1

@wuwz98

Description

@wuwz98

Lecture 10 Semaphores II
page 15, the sudocode for the two threads in the critical section:
B[in] = product;
in = (in + 1) % k;
product = B[out];
out = (out + 1) % k;
look suspicious to me.

Maybe it should be like this.
for the Producer process:
B[in] = product;
in = in + 1;
out = out + 1;
for the Consumer process:
product = B[out];
in = in - 1;
out = out - 1;

Since we already have empty and full semaphore set to be the maxium size of the butter, we don't need to worry about index out of bound.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions