Changeset 431 for branches/thune/thread_safe/thread.c
- Timestamp:
- 07/16/07 03:30:29 (17 months ago)
- Files:
-
- 1 modified
-
branches/thune/thread_safe/thread.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/thune/thread_safe/thread.c
r408 r431 38 38 39 39 40 extern UCellContext ur_thrGlobal; 41 40 42 UThread* ur_threadMake( UrlanEnv* env, int binCount, int blkCount ) 41 43 { … … 53 55 if( env->threads ) 54 56 { 57 #if 0 55 58 UThread* link = env->threads; 56 59 ut->nextThread = link->nextThread; 57 60 link->nextThread = ut; 61 #endif 58 62 } 59 63 else … … 71 75 //ur_hold( ut, UT_BINARY, binN ); // Hardcoded in recycle 72 76 } 77 78 // Make hold & global context blocks. 79 ur_makeBlock( 8 ); // 0 - BLK_THREAD_HOLD 80 ur_makeBlock( 1024 ); // 1 - BLK_GLOBAL_WORD 81 ur_makeBlock( 1024 ); // 2 - BLK_GLOBAL_VAL 82 ur_makeBlock( 1 ); // 3 - BLK_CTX_STACK 83 //ur_makeBlock( 0 ); // 4 - BLK_DSTACK 84 85 ur_pushContext( ut, (UCell*) &ur_thrGlobal ); 73 86 } 74 87 return ut; … … 76 89 77 90 78 #ifdef UR_CONFIG_THREADS 91 /* 79 92 void ur_threadUnlink( UThread* th ) 80 93 { … … 82 95 it = ((UrlanEnv*) th->env)->threads; 83 96 if( it == th ) 84 ((UrlanEnv*) th->env)->threads = (UThread*) th->nextThread; 85 while( it->nextThread != th ) 86 it = it->nextThread; 87 it->nextThread = th->nextThread; 97 ((UrlanEnv*) th->env)->threads = (UThread*) th->nextTask; 98 while( it->nextTask != th ) 99 it = it->nextTask; 100 it->nextTask = th->nextTask; 101 } 102 */ 103 104 105 #ifdef UR_CONFIG_TASKS 106 void ur_taskUnlink( UThread* th ) 107 { 108 UThread* it; 109 it = ((UrlanEnv*) th->env)->threads; 110 if( it == th ) 111 ((UrlanEnv*) th->env)->threads = (UThread*) th->nextTask; 112 while( it->nextTask != th ) 113 it = it->nextTask; 114 it->nextTask = th->nextTask; 88 115 } 89 116 90 117 91 118 // Returns zero and sets error if no threads are ready. 92 UThread* ur_t hreadNextReady( UThread* cur )119 UThread* ur_taskNextReady( UThread* cur ) 93 120 { 94 121 UThread* next = cur; … … 96 123 do 97 124 { 98 next = next->nextT hread;99 if( next->state == UR_T HREAD_READY )100 { 101 next->state = UR_T HREAD_RUNNING;125 next = next->nextTask; 126 if( next->state == UR_TASK_READY ) 127 { 128 next->state = UR_TASK_RUNNING; 102 129 return next; 103 130 } 104 else if( next->state == UR_T HREAD_BLOCKED )131 else if( next->state == UR_TASK_BLOCKED ) 105 132 { 106 133 UCell* pc; … … 113 140 if( pc && ! ur_is(pc, UT_UNSET) ) 114 141 { 115 next->state = UR_T HREAD_RUNNING;142 next->state = UR_TASK_RUNNING; 116 143 return next; 117 144 } … … 121 148 while( next != cur ); 122 149 123 ur_throwErr( cur, UR_EX_SCRIPT, "All t hreads are blocked" );150 ur_throwErr( cur, UR_EX_SCRIPT, "All tasks are blocked" ); 124 151 return 0; 125 152 } … … 145 172 */ 146 173 147 th->state = UR_T HREAD_READY;174 th->state = UR_TASK_READY; 148 175 th->callOp = 0; 149 176 th->tos = th->dstack; … … 183 210 184 211 /** 185 \return scell pointer to TOS.212 \return cell pointer to TOS. 186 213 Pops TOS if pop is non-zero. 187 214 */
