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.