正在加载图片...
Multithreaded Unpredictability Many things that look like "one step"operations actually take several steps under the hood: Thread 1: Thread 2: void foo(){ void bar() eax mem[x]; eax mem[y]; inc eax; inc eax; mem[x]eax; mem[y]eax; ebx mem[x]; eax mem[x]; mem[y]ebx; inc eax; mem[x]eax; When we run a multithreaded program,we don't know what order threads run in,nor do we know when they will interrupt one another.Multithreaded = Unpredictability ◼ When we run a multithreaded program, we don’t know what order threads run in, nor do we know when they will interrupt one another. Thread 1: void foo() { eax = mem[x]; inc eax; mem[x] = eax; ebx = mem[x]; mem[y] = ebx; } Thread 2: void bar() { eax = mem[y]; inc eax; mem[y] = eax; eax = mem[x]; inc eax; mem[x] = eax; } ◼ Many things that look like “one step” operations actually take several steps under the hood:
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有