Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check usage of Semaphores #350

Closed
MichaelRoeder opened this issue Apr 24, 2020 · 0 comments · Fixed by #351
Closed

Check usage of Semaphores #350

MichaelRoeder opened this issue Apr 24, 2020 · 0 comments · Fixed by #351
Assignees
Labels
SHK The task has a difficulty which can be handled by a student developer type:bug

Comments

@MichaelRoeder
Copy link
Member

Description

Using Semaphores becomes an issue if "permits" are lost, e.g., if an exception is thrown between acquiring and releasing a permit.

semaphore.acquire();
// do something that causes an exception
semaphore.release();

To this end, it should look like the following:

semaphore.acquire();
try {
    // do something that causes an exception
} finally {
    semaphore.release();
}

It should be noted that the try block does not need a catch block, i.e., it is not necessary to handle the exception at this place. The important point is that releasing the permit is done within the finally block and will be executed whenever the program leaves the try block.

Task

We should go through all usages of Semaphores in GERBIL to ensure that all of them are used like described above. This is necessary to avoid issues like #348.

@MichaelRoeder MichaelRoeder added the SHK The task has a difficulty which can be handled by a student developer label Apr 24, 2020
MichaelRoeder added a commit that referenced this issue May 1, 2020
Fixed #350 Checked usage of semaphores
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SHK The task has a difficulty which can be handled by a student developer type:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants