Previous | Next --- Slide 13 of 72
Back to Lecture Thumbnails
aabhagwa

A topic of ongoing research in programming languages is expressing concurrent message-passing through session types (https://www.cs.cmu.edu/~fp/papers/cc016.pdf). Session types are a way to let a typechecker statically check that concurrent code is safe and will satisfy certain properties (such as deadlock-free-ness).

paramecinm

Is there any benefit to use sync calls like this rather than use async calls? I think writing code like this is a little wired.

Metalbird

@paramecinm I think the benefit of using sync call is that they block, while async calls do not. what I mean is if you have an application where you need to wait for the data to be communicated and you cannot proceed past it, then you can not use an async call cause then you may perform calculations on the wrong data. Ideally, async calls should be ideal so that you can perform more calculations, but sequential parts of the code may require sync calls.

zale

But we could imagine an implementation where async calls get and send the data, the receivers set a semaphore when they're done.

Of course the deeper problem may be that these async calls will probably be implemented using pthreads or a similar abstraction, thus causing context switches and making this less efficient.