Skip to content

Fix typos in mpmc #2

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

Merged
merged 1 commit into from
May 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions mpmc/mpmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ enum queue_ops {
DEQ = 1 << 0,
};

/* regiseter the enqueuers first, dequeuers second. */
/* register the enqueuers first, dequeuers second. */
void mpmc_queue_register(mpmc_t *q, handle_t *th, int flag)
{
th->spare = mpmc_new_node();
Expand Down Expand Up @@ -122,8 +122,8 @@ static void *mpmc_find_cell(node_t *volatile *ptr, long i, handle_t *th)
{
node_t *curr = *ptr; /* get current node */

/* j is thread's local node'id (put node or pop node), (i / N) is the cell
* needed node'id. and we shoud take it, By filling the nodes between the j
/* j is thread's local node id (put node or pop node), (i / N) is the cell
* needed node id. and we should take it, By filling the nodes between the j
* and (i / N) through 'next' field
*/
for (long j = curr->id; j < i / N; ++j) {
Expand Down Expand Up @@ -198,8 +198,8 @@ void mpmc_enqueue(mpmc_t *q, handle_t *th, void *v)
if ((cv = __atomic_exchange_n(c, v, __ATOMIC_ACQ_REL)) == NULL)
return;

/* else the couterpart pop thread has wait this cell, so we just change the
* wating value to 0 and wake it
/* else the counterpart pop thread has wait this cell, so we just change the
* waiting value to 0 and wake it
*/
*((int *) cv) = 0;
mpmc_futex_wake(cv, 1);
Expand Down Expand Up @@ -236,7 +236,7 @@ void *mpmc_dequeue(mpmc_t *q, handle_t *th)
mpmc_futex_wait(&futex_addr, 1);
} while (futex_addr == 1);

/* the couterpart put thread has change futex_addr's value to 0. and the
/* the counterpart put thread has change futex_addr's value to 0. and the
* data has into cell(c).
*/
cv = *c;
Expand Down Expand Up @@ -293,7 +293,7 @@ void *mpmc_dequeue(mpmc_t *q, handle_t *th)
if (new_id <= init_index)
/* __atomic_store_n(ptr, val, __ATOMIC_RELEASE) is a store with
* a preceding release fence to ensure all previous load and
* stores completes before the current store is visiable.
* stores completes before the current store is visible.
*/
__atomic_store_n(&q->init_id, init_index, __ATOMIC_RELEASE);
else {
Expand Down