threads/model: allocate Thread from w/in ModelChecker
authorBrian Norris <banorris@uci.edu>
Wed, 19 Dec 2012 01:46:40 +0000 (17:46 -0800)
committerBrian Norris <banorris@uci.edu>
Thu, 14 Feb 2013 20:25:04 +0000 (12:25 -0800)
commit82df62c2b0805848b87bb71df5b66a4a66f8e25d
tree9dff24e0457d89c98150e5d029c60afe1c0a40f5
parent3796989e962917277d76de4bf0ef9dc9d2bc0ff2
threads/model: allocate Thread from w/in ModelChecker

It adds scheduling difficulties if we allocate/schedule a Thread from
the user-context (i.e., directly from the thrd_create() interface)
because then it is not necessarily atomic. For example, if we run a
thread up to its context switch for a THREAD_CREATE then switch to
another thread before the THREAD_CREATE is processed, then we will
already have constructed a Thread from the first thread (and prepared it
for scheduling) without processing it in the ModelChecker appropriately.
For instance, the following schedule might appear, causing problems:

 TID    ACTION
 ---    ------
    ...
  1     ATOMIC_READ         <--- Next action is THREAD_CREATE
 (1)    (construct Thread 3)
 (1)    (prepare new Thread for Scheduling)
  2     ATOMIC_READ
  3     THREAD_START        <--- Before its CREATE event??
  1     THREAD_CREATE

Note that this scheduling does not yet happen, as we always execute
the "lead-in" to THREAD_CREATE atomically. This may change, though.
action.cc
libthreads.cc
model.cc
nodestack.cc
threads-model.h