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

Use possibly ANY2ANY channels if necessary and fix ...ANY for alts if possible #26

Open
arian opened this issue Jan 4, 2016 · 0 comments
Labels

Comments

@arian
Copy link
Owner

arian commented Jan 4, 2016

When communicating between multiple processes, with multiple channels, having ONE2ONE type channels could deadlock. We don't want that.

#include <stdio.h>
#include <unistd.h>

process print(char *label, chan<char> c, chan<int> c2) {
  while (1) {
    char foo = c?;
    printf("%s %c\n", label, foo);
    c2 ! 0;
  }
}

process writer(char label, int delay, chan<char> c, chan<int> c2) {
  while (1) {
    usleep(delay);
    c ! label;
    c2?;
    printf("%c\n", label);
  }
}

int main() {
  chan<char> c;
  chan<int> c2;
  par {
    print("P", c, c2);
    writer('A', 10e4, c, c2);
    writer('B', 10e4, c, c2);
    writer('C', 10e4, c, c2);
  }
  return 0;
}

Depending on the thread that runs first (which is not deterministic), it might deadlock or not. If using ANY2ONE_CHANNEL and ONE2ANY_CHANNEL types for c and c2 respectively, the problem is solved.

Two things need to be solved to fix this:

  1. statically determine which channel type to choose
  2. come up with a solution for CSP_priAltselect, that only accepts ONE2ONE and ANY2ONE.
@arian arian added the dataflow label Jan 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant