Changes in kernel/generic/src/ipc/ipcrsc.c [da1bafb:2c0e5d2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/ipcrsc.c
rda1bafb r2c0e5d2 45 45 * - hangup phone (the caller has hung up) 46 46 * - hangup phone (the answerbox is exiting) 47 * 47 * 48 48 * Locking strategy 49 49 * … … 85 85 * 86 86 * Phone hangup 87 * 87 * 88 88 * *** The caller hangs up (sys_ipc_hangup) *** 89 89 * - The phone is disconnected (no more messages can be sent over this phone), … … 99 99 * 100 100 * Call forwarding 101 * 101 * 102 102 * The call can be forwarded, so that the answer to call is passed directly 103 103 * to the original sender. However, this poses special problems regarding … … 114 114 * 115 115 * Cleanup strategy 116 * 116 * 117 117 * 1) Disconnect all our phones ('ipc_phone_hangup'). 118 118 * … … 123 123 * 124 124 * 4) Wait for all async answers to arrive and dispose of them. 125 * 125 * 126 126 */ 127 127 … … 137 137 * @todo Some speedup (hash table?) 138 138 * 139 * @param callid Userspace hash of the call. Currently it is the call 140 * structure kernel address. 141 * 142 * @return NULL on not found, otherwise pointer to the call 143 * structure. 144 * 139 * @param callid Userspace hash of the call. Currently it is the call 140 * structure kernel address. 141 * 142 * @return NULL on not found, otherwise pointer to the call 143 * structure. 145 144 */ 146 145 call_t *get_call(unative_t callid) 147 146 { 148 147 link_t *lst; 149 call_t * result = NULL;150 151 irq_spinlock_lock(&TASK->answerbox.lock, true);148 call_t *call, *result = NULL; 149 150 spinlock_lock(&TASK->answerbox.lock); 152 151 for (lst = TASK->answerbox.dispatched_calls.next; 153 152 lst != &TASK->answerbox.dispatched_calls; lst = lst->next) { 154 call _t *call= list_get_instance(lst, call_t, link);153 call = list_get_instance(lst, call_t, link); 155 154 if ((unative_t) call == callid) { 156 155 result = call; … … 158 157 } 159 158 } 160 161 irq_spinlock_unlock(&TASK->answerbox.lock, true); 159 spinlock_unlock(&TASK->answerbox.lock); 162 160 return result; 163 161 } … … 165 163 /** Allocate new phone slot in the specified task. 166 164 * 167 * @param task Task for which to allocate a new phone. 168 * 169 * @return New phone handle or -1 if the phone handle limit is 170 * exceeded. 171 * 172 */ 173 int phone_alloc(task_t *task) 174 { 175 irq_spinlock_lock(&task->lock, true); 176 177 size_t i; 165 * @param t Task for which to allocate a new phone. 166 * 167 * @return New phone handle or -1 if the phone handle limit is 168 * exceeded. 169 */ 170 int phone_alloc(task_t *t) 171 { 172 int i; 173 174 spinlock_lock(&t->lock); 178 175 for (i = 0; i < IPC_MAX_PHONES; i++) { 179 if ( (task->phones[i].state == IPC_PHONE_HUNGUP)&&180 (atomic_get(&task->phones[i].active_calls) == 0))181 t ask->phones[i].state = IPC_PHONE_FREE;182 183 if (t ask->phones[i].state == IPC_PHONE_FREE) {184 t ask->phones[i].state = IPC_PHONE_CONNECTING;176 if (t->phones[i].state == IPC_PHONE_HUNGUP && 177 atomic_get(&t->phones[i].active_calls) == 0) 178 t->phones[i].state = IPC_PHONE_FREE; 179 180 if (t->phones[i].state == IPC_PHONE_FREE) { 181 t->phones[i].state = IPC_PHONE_CONNECTING; 185 182 break; 186 183 } 187 184 } 188 189 irq_spinlock_unlock(&task->lock, true); 190 185 spinlock_unlock(&t->lock); 186 191 187 if (i == IPC_MAX_PHONES) 192 188 return -1; 193 189 194 190 return i; 195 191 } … … 197 193 /** Mark a phone structure free. 198 194 * 199 * @param phone Phone structure to be marked free. 200 * 195 * @param phone Phone structure to be marked free. 201 196 */ 202 197 static void phone_deallocp(phone_t *phone) … … 204 199 ASSERT(phone->state == IPC_PHONE_CONNECTING); 205 200 206 /* Atomic operation */201 /* atomic operation */ 207 202 phone->state = IPC_PHONE_FREE; 208 203 } … … 212 207 * All already sent messages will be correctly processed. 213 208 * 214 * @param phoneid Phone handle of the phone to be freed. 215 * 209 * @param phoneid Phone handle of the phone to be freed. 216 210 */ 217 211 void phone_dealloc(int phoneid) … … 222 216 /** Connect phone to a given answerbox. 223 217 * 224 * @param phoneid Phone handle to be connected.225 * @param box 218 * @param phoneid Phone handle to be connected. 219 * @param box Answerbox to which to connect the phone handle. 226 220 * 227 221 * The procedure _enforces_ that the user first marks the phone 228 222 * busy (e.g. via phone_alloc) and then connects the phone, otherwise 229 223 * race condition may appear. 230 *231 224 */ 232 225 void phone_connect(int phoneid, answerbox_t *box)
Note:
See TracChangeset
for help on using the changeset viewer.