Better HN
topnewbestaskshowjobs
Log inSign up

johnhamlet

-4 karma · joined Jan 4, 2014 (12y ago) · 5 submissions

Submissions

comment 12y ago · link · parent

What does C++11's definitions have to do with anything? This is Rust.

comment 12y ago · link · parent

You: "not every non-deterministic piece of code is a race-condition"

Wikipedia: "A race condition ... is ... where the output is dependent on the sequence or timing..."

Boom! Headshot!

comment 12y ago · link · parent

...but you can still have races with locking.

Data races don't mean data corruption. It simply means the result is dependent on the scheduler or something else out of your control.

Two threads set a shared variable to different values. They both lock it before the set it. But that's still a data race, as which thread write first is dependent on the scheduler.

comment 12y ago · link · parent

Two tasks A and B both send a message to task C. Does the message from A or the message from B get received by task C first? That's a race condition.

"A race condition or race hazard is the behavior of an electronic or software system where the output is dependent on the sequence or timing of other uncontrollable events."

"It becomes a bug when events do not happen in the order the programmer intended."

http://en.wikipedia.org/wiki/Race_condition

If I thought that the message A would definitely get there first - who knows why but that's what I thought when I wrote the code - this is a race condition and a bug.

Please explain to me - how does the compiler prevent this race condition and bug?

comment 12y ago · link · parent

"The Rust compiler normally disallows any code with race conditions"

Lol what? Unless tasks cannot communicate at all, or they are scheduled entirely deterministically, how can the compiler eliminate race conditions? How can a compiler even determine what is a race conditions and what is intended non-determinstic behaviour.