- threads_table.table[size-1].nextfree = 0; /* index 0 is never free */
-}
-
-
-/* threads_table_add **********************************************************
-
- Add a thread to the global threads table. The index is entered in the
- threadobject. The thinlock value for the thread is pre-computed.
-
- IN:
- thread............the thread to add
-
- RETURN VALUE:
- The table index for the newly added thread. This value has also been
- entered in the threadobject.
-
- PRE-CONDITION:
- The caller must hold the threadlistlock!
-
-******************************************************************************/
-
-static s4 threads_table_add(threadobject *thread)
-{
- s4 index;
- s4 oldsize;
- s4 newsize;
- s4 i;
-
- /* table[0] serves as the head of the freelist */
-
- index = threads_table.table[0].nextfree;
-
- /* if we got a free index, use it */
-
- if (index) {
-got_an_index:
- threads_table.table[0].nextfree = threads_table.table[index].nextfree;
- threads_table.table[index].thread = thread;
- thread->index = index;
- thread->thinlock = lock_pre_compute_thinlock(index);
- return index;
- }
-
- /* we must grow the table */
-
- oldsize = threads_table.size;
- newsize = oldsize * 2;
-
- threads_table.table = MREALLOC(threads_table.table, threads_table_entry_t,
- oldsize, newsize);
- threads_table.size = newsize;
-
- /* link the new entries to a free list */
-
- for (i=oldsize; i<newsize; ++i) {
- threads_table.table[i].nextfree = i+1;