Changes in kernel/generic/src/ipc/ipcrsc.c [2c0e5d2:da1bafb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/ipcrsc.c
r2c0e5d2 rda1bafb 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. 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 * 144 145 */ 145 146 call_t *get_call(unative_t callid) 146 147 { 147 148 link_t *lst; 148 call_t * call, *result = NULL;149 150 spinlock_lock(&TASK->answerbox.lock);149 call_t *result = NULL; 150 151 irq_spinlock_lock(&TASK->answerbox.lock, true); 151 152 for (lst = TASK->answerbox.dispatched_calls.next; 152 153 lst != &TASK->answerbox.dispatched_calls; lst = lst->next) { 153 call = list_get_instance(lst, call_t, link);154 call_t *call = list_get_instance(lst, call_t, link); 154 155 if ((unative_t) call == callid) { 155 156 result = call; … … 157 158 } 158 159 } 159 spinlock_unlock(&TASK->answerbox.lock); 160 161 irq_spinlock_unlock(&TASK->answerbox.lock, true); 160 162 return result; 161 163 } … … 163 165 /** Allocate new phone slot in the specified task. 164 166 * 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); 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; 175 178 for (i = 0; i < IPC_MAX_PHONES; i++) { 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;179 if ((task->phones[i].state == IPC_PHONE_HUNGUP) && 180 (atomic_get(&task->phones[i].active_calls) == 0)) 181 task->phones[i].state = IPC_PHONE_FREE; 182 183 if (task->phones[i].state == IPC_PHONE_FREE) { 184 task->phones[i].state = IPC_PHONE_CONNECTING; 182 185 break; 183 186 } 184 187 } 185 spinlock_unlock(&t->lock); 186 188 189 irq_spinlock_unlock(&task->lock, true); 190 187 191 if (i == IPC_MAX_PHONES) 188 192 return -1; 189 193 190 194 return i; 191 195 } … … 193 197 /** Mark a phone structure free. 194 198 * 195 * @param phone Phone structure to be marked free. 199 * @param phone Phone structure to be marked free. 200 * 196 201 */ 197 202 static void phone_deallocp(phone_t *phone) … … 199 204 ASSERT(phone->state == IPC_PHONE_CONNECTING); 200 205 201 /* atomic operation */206 /* Atomic operation */ 202 207 phone->state = IPC_PHONE_FREE; 203 208 } … … 207 212 * All already sent messages will be correctly processed. 208 213 * 209 * @param phoneid Phone handle of the phone to be freed. 214 * @param phoneid Phone handle of the phone to be freed. 215 * 210 216 */ 211 217 void phone_dealloc(int phoneid) … … 216 222 /** Connect phone to a given answerbox. 217 223 * 218 * @param phoneid 219 * @param box 224 * @param phoneid Phone handle to be connected. 225 * @param box Answerbox to which to connect the phone handle. 220 226 * 221 227 * The procedure _enforces_ that the user first marks the phone 222 228 * busy (e.g. via phone_alloc) and then connects the phone, otherwise 223 229 * race condition may appear. 230 * 224 231 */ 225 232 void phone_connect(int phoneid, answerbox_t *box)
Note:
See TracChangeset
for help on using the changeset viewer.