Changeset c4c5de5 in mainline for libc/generic/psthread.c
- Timestamp:
- 2006-03-24T14:29:19Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8fe1cdb
- Parents:
- 520492a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/generic/psthread.c
r520492a rc4c5de5 40 40 static void psthread_main(void); 41 41 42 /** Setup PSthread information into TCB structure */ 43 psthread_data_t * psthread_setup(tcb_t *tcb) 44 { 45 psthread_data_t *pt; 46 47 pt = malloc(sizeof(*pt)); 48 if (!pt) { 49 return NULL; 50 } 51 52 tcb->pst_data = pt; 53 pt->tcb = tcb; 54 55 return pt; 56 } 57 58 void psthread_teardown(psthread_data_t *pt) 59 { 60 free(pt); 61 } 62 42 63 /** Function to preempt to other pseudo thread without adding 43 64 * currently running pseudo thread to ready_list. … … 60 81 void psthread_main(void) 61 82 { 62 psthread_data_t *pt = __tls_get(); 83 psthread_data_t *pt = __tcb_get()->pst_data; 84 63 85 pt->retval = pt->func(pt->arg); 64 86 … … 81 103 return 0; 82 104 83 pt = __t ls_get();105 pt = __tcb_get()->pst_data; 84 106 if (!context_save(&pt->ctx)) 85 107 return 1; … … 104 126 105 127 /* Handle psthrid = Kernel address -> it is wait for call */ 106 107 128 pt = (psthread_data_t *) psthrid; 108 129 109 130 if (!pt->finished) { 110 mypt = __t ls_get();131 mypt = __tcb_get()->pst_data; 111 132 if (context_save(&((psthread_data_t *) mypt)->ctx)) { 112 133 pt->waiter = (psthread_data_t *) mypt; … … 117 138 118 139 free(pt->stack); 119 __free_tls((psthread_data_t *) pt); 140 __free_tls(pt->tcb); 141 psthread_teardown((void *)pt); 120 142 121 143 return retval; … … 133 155 { 134 156 psthread_data_t *pt; 157 tcb_t *tcb; 135 158 136 pt = __make_tls(); 159 tcb = __make_tls(); 160 if (!tcb) 161 return 0; 162 163 pt = psthread_setup(tcb); 164 if (!pt) { 165 __free_tls(tcb); 166 return 0; 167 } 137 168 pt->stack = (char *) malloc(getpagesize()); 138 169 139 170 if (!pt->stack) { 171 __free_tls(tcb); 172 psthread_teardown(pt); 140 173 return 0; 141 174 } … … 147 180 148 181 context_save(&pt->ctx); 149 context_set(&pt->ctx, FADDR(psthread_main), pt->stack, getpagesize(), pt); 182 context_set(&pt->ctx, FADDR(psthread_main), pt->stack, getpagesize(), 183 tcb); 150 184 151 185 list_append(&pt->link, &ready_list);
Note:
See TracChangeset
for help on using the changeset viewer.