7 ms·
Multithreading sacrifices determinism. So, regardless of what you tell it you can't make any claims of exactness about what it's doing.
by KeithMajhor 16y ago
Multithreading sacrifices determinism. So, regardless of what you tell it you can't make any claims of exactness about what it's doing.
- dhume 16y agoThe programmer is still allowed to specify operations to perform as well as restrictions on the order in which the operations are performed. Not fully specifying what to do just gives the computer more options to pick from -- it will still pick one of those options.
- AgentConundrum 16y agoit will still pick one of those options which is the part that gets rid of the "does what you tell it" bit, since now it's doing what it thinks it should, which might not be very consistent or easily determinable because minor variations during a race can produce wildly differing results.
- dhume 16y agoIf I tell someone, "bring me a sandwich or a bowl of chili," and the person brings me a bowl of chili, that person has done exactly what I told them to do.
- regularfry 16y agoWhat if they get bored waiting at the counter in the cafe and come back empty-handed? 'Cos that's what can happen as soon as IO is allowed into the picture; particularly so with network IO.
- deleted 16y ago[deleted]
- sambe 16y agoIn that case you probably said "get me a bowl of chili if you can get served in a minute, otherwise don't bother". Or at least it was implicit.
- regularfry 16y agoThe problem is that combining this with multithreading makes for a combinatorial explosion of possible states that you might have to deal with. It's just not feasible to exhaustively specify everything., and leaving things implicit means that you're expecting the computer to do things you haven't told it to do.
- sambe 16y agoSure, there is complexity. It's easy to make assumptions or forget real-world details too. But you DID tell it to time-out, because that's how the I/O library is specified.
- regularfry 16y agoThe more pernicious problem is when they don't come back at all, having deadlocked.
- extension 16y agoThe computer is still deterministic, but somebody lower in the technology stack doesn't want to completely define its behavior.
- KeithMajhor 16y agoYou're right. However, from the perspective of the programmer it is non-deterministic. It only becomes deterministic when it is coupled with a particular scheduler and dispatcher. Most programmers strive to write cross platform code.
- gnaritas 16y ago> Most programmers strive to write cross platform code. On what planet? Surely not this one, as most programs are very tightly coupled to particular operating systems.
- KeithMajhor 16y agoRude, but whatever... you might be right. Regardless, a future version of any single platform could include changes to the scheduler and/or dispatcher.
- gnaritas 16y agoHm, sorry, didn't mean to be.
- nikster 16y agoIf it's non-deterministic, you're not doing it right.
- KeithMajhor 16y agoThat's false. If you're doing it "right" then it will produce the same functional output for all of the possible execution paths. That doesn't make it deterministic.
- hasenj 16y agoIt's still deterministic; just not by you: by the kernel.
- philwelch 16y agoPhilosophically, it's deterministic. In engineering terms, it's non-deterministic from the perspective of the application programmer.
- Locke1689 16y agoPhilisophically, you can't say either way. For example, consider the case where the kernel scheduler uses random numbers from a hardware random number generator which uses quantum uncertainty. Since physics doesn't know whether or not quantum mechanics is deterministic, we can't say whether or not this system is deterministic.
- philwelch 16y agoI was assuming a deterministic scheduler, but sure. I wasn't aware that hardware RNG's were commonly used by kernel schedulers.
- Dylan16807 16y agoIf the cores aren't at the same speed it can probably happen.
- hasenj 16y ago> Since physics doesn't know whether or not quantum mechanics is deterministic Just because we don't know the laws that govern quantum mechanics doesn't mean they're not there.
- Natsu 16y agoKnowing the laws wouldn't necessarily make the system deterministic, though. You'd need hidden variables (and non-local ones, to boot). As best we can tell, sometimes certain information doesn't exist so you may very well get something truly random that averages out to something that looks like what we think of as deterministic, classical behavior.
- jules 16y agoIf you're using threads you told it to be non deterministic. So it's still doing what you told it to.
- j_baker 16y agoTrue, but my point is still valid. When you start a thread, you're saying "do this these tasks in whatever order is most convenient for you". And the computer does just that.