Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3020 → Rev 3019

/trunk/kernel/generic/src/ipc/sysipc.c
168,7 → 168,7
/* In case of forward, hangup the forwared phone,
* not the originator
*/
mutex_lock(&answer->data.phone->lock);
spinlock_lock(&answer->data.phone->lock);
spinlock_lock(&TASK->answerbox.lock);
if (answer->data.phone->state == IPC_PHONE_CONNECTED) {
list_remove(&answer->data.phone->link);
175,7 → 175,7
answer->data.phone->state = IPC_PHONE_SLAMMED;
}
spinlock_unlock(&TASK->answerbox.lock);
mutex_unlock(&answer->data.phone->lock);
spinlock_unlock(&answer->data.phone->lock);
}
 
if (!olddata)
/trunk/kernel/generic/src/ipc/ipc.c
37,9 → 37,7
* First the answerbox, then the phone.
*/
 
#include <synch/synch.h>
#include <synch/spinlock.h>
#include <synch/mutex.h>
#include <synch/waitq.h>
#include <synch/synch.h>
#include <ipc/ipc.h>
142,7 → 140,7
*/
void ipc_phone_connect(phone_t *phone, answerbox_t *box)
{
mutex_lock(&phone->lock);
spinlock_lock(&phone->lock);
 
phone->state = IPC_PHONE_CONNECTED;
phone->callee = box;
151,7 → 149,7
list_append(&phone->link, &box->connected_phones);
spinlock_unlock(&box->lock);
 
mutex_unlock(&phone->lock);
spinlock_unlock(&phone->lock);
}
 
/** Initialize a phone structure.
160,7 → 158,7
*/
void ipc_phone_init(phone_t *phone)
{
mutex_initialize(&phone->lock);
spinlock_initialize(&phone->lock, "phone_lock");
phone->callee = NULL;
phone->state = IPC_PHONE_FREE;
atomic_set(&phone->active_calls, 0);
263,9 → 261,9
{
answerbox_t *box;
 
mutex_lock(&phone->lock);
spinlock_lock(&phone->lock);
if (phone->state != IPC_PHONE_CONNECTED) {
mutex_unlock(&phone->lock);
spinlock_unlock(&phone->lock);
if (call->flags & IPC_CALL_FORWARDED) {
IPC_SET_RETVAL(call->data, EFORWARD);
_ipc_answer_free_call(call);
280,7 → 278,7
box = phone->callee;
_ipc_call(phone, box, call);
mutex_unlock(&phone->lock);
spinlock_unlock(&phone->lock);
return 0;
}
 
299,11 → 297,11
answerbox_t *box;
call_t *call;
mutex_lock(&phone->lock);
spinlock_lock(&phone->lock);
if (phone->state == IPC_PHONE_FREE ||
phone->state == IPC_PHONE_HUNGUP ||
phone->state == IPC_PHONE_CONNECTING) {
mutex_unlock(&phone->lock);
spinlock_unlock(&phone->lock);
return -1;
}
box = phone->callee;
322,7 → 320,7
}
 
phone->state = IPC_PHONE_HUNGUP;
mutex_unlock(&phone->lock);
spinlock_unlock(&phone->lock);
 
return 0;
}
451,7 → 449,7
while (!list_empty(&TASK->answerbox.connected_phones)) {
phone = list_get_instance(TASK->answerbox.connected_phones.next,
phone_t, link);
if (SYNCH_FAILED(mutex_trylock(&phone->lock))) {
if (!spinlock_trylock(&phone->lock)) {
spinlock_unlock(&TASK->answerbox.lock);
DEADLOCK_PROBE(p_phonelck, DEADLOCK_THRESHOLD);
goto restart_phones;
462,7 → 460,7
phone->state = IPC_PHONE_SLAMMED;
list_remove(&phone->link);
 
mutex_unlock(&phone->lock);
spinlock_unlock(&phone->lock);
}
 
/* Answer all messages in 'calls' and 'dispatched_calls' queues */
537,10 → 535,7
/* Print opened phones & details */
printf("PHONE:\n");
for (i = 0; i < IPC_MAX_PHONES; i++) {
if (SYNCH_FAILED(mutex_trylock(&task->phones[i].lock))) {
printf("%d: mutex busy\n", i);
continue;
}
spinlock_lock(&task->phones[i].lock);
if (task->phones[i].state != IPC_PHONE_FREE) {
printf("%d: ", i);
switch (task->phones[i].state) {
565,7 → 560,7
printf("active: %d\n",
atomic_get(&task->phones[i].active_calls));
}
mutex_unlock(&task->phones[i].lock);
spinlock_unlock(&task->phones[i].lock);
}
 
 
584,7 → 579,7
}
/* Print answerbox - calls */
printf("ABOX - DISPATCHED CALLS:\n");
for (tmp = task->answerbox.dispatched_calls.next;
for (tmp=task->answerbox.dispatched_calls.next;
tmp != &task->answerbox.dispatched_calls;
tmp = tmp->next) {
call = list_get_instance(tmp, call_t, link);
/trunk/kernel/generic/include/ipc/ipc.h
205,8 → 205,6
 
#define IPC_MAX_PHONES 16
 
#include <synch/spinlock.h>
#include <synch/mutex.h>
#include <synch/waitq.h>
 
struct answerbox;
227,7 → 225,7
 
/** Structure identifying phone (in TASK structure) */
typedef struct {
mutex_t lock;
SPINLOCK_DECLARE(lock);
link_t link;
struct answerbox *callee;
ipc_phone_state_t state;