int find(a, x)
  i = a.length
  while --i > -1
    if a[i] == x, break
  return i
i = a.length; --i > -1; a[i] == x; ...
| 
 
 | 
 | 

| 
 
 |  | 
| 
 | 
int pthread_create( thread id, out to caller thread attributes, stack, priority, ... thread function, statements thread arguments) to the function void pthread_exit(result) int pthread_join( thread id, result)

class P implements Runnable { ... }
class C implements Runnable { ... }
main()
  Queue q = new Queue()
  Thread p = new Thread(new P(q))
  Thread c = new Thread(new C(q))
  p.run() ; c.run()
  p.join() ; c.join()
switch pid = fork()
  case 0
    execve("null-process")
  case -1
    // fork() failed
  default
    const pid_t p = wait()
    if (p == -1)
      // wait() failed
    if (p != pid)
      // unexpected pid from wait() 
s = pthread_create(&tid, NULL, null_thread, NULL); if (s != 0) // pthread_create() failed s = pthread_join(tid, NULL) if (s != 0) // pthread_join() failed void * null_thread(void *) pthread_exit(NULL)
| avg, std dev | |||||
| threads | processes | ||||
| n = 100 | 123, 158 | 1730, 180 | |||
| n = 1000 | 77, 41 | 1590, 321 | |||
#include <setjmp.h> int setjmp(jmp_buf env) void longjmp(jmp_buf env, int val)
setjmp() takes a location snapshot.
    longjmp() jumps to a location snapshot.
    | 
 
 |  | 
| 
 
 | 
 | 
| 
 
 | 
 | 
| This page last modified on 2012 February 6. |