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

Why setting cv->head to next of new node #186

Open
WweiL opened this issue Oct 2, 2021 · 2 comments
Open

Why setting cv->head to next of new node #186

WweiL opened this issue Oct 2, 2021 · 2 comments

Comments

@WweiL
Copy link
Contributor

WweiL commented Oct 2, 2021

cv->head = my_node.next;

I was wondering the purpose of this line here. It seems that it is setting the head again to itself so essentially this line doesn't do anything. Should it be setting head to my_node?

@WweiL
Copy link
Contributor Author

WweiL commented Oct 2, 2021

Also I believe

while(my_node == 0) {

should be

while(my_node.is_awoken == 0) {

@WweiL
Copy link
Contributor Author

WweiL commented Oct 2, 2021

And probably the mutex dynamic inside

typedef struct cv_node_ {
pthread_mutex_t *dynamic;
int is_awoken;
struct cv_node_ *next;
} cv_node;

should rather be defined inside

typedef struct {
cv_node_ *head
} cond_t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant