Changeset ff48a15 in mainline


Ignore:
Timestamp:
2008-05-28T20:47:45Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
33c058d3
Parents:
10ef329a
Message:

Turn phone→lock into mutex.

Location:
kernel/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ipc/ipc.h

    r10ef329a rff48a15  
    206206#define IPC_MAX_PHONES  16
    207207
     208#include <synch/spinlock.h>
     209#include <synch/mutex.h>
    208210#include <synch/waitq.h>
    209211
     
    226228/** Structure identifying phone (in TASK structure) */
    227229typedef struct {
    228         SPINLOCK_DECLARE(lock);
     230        mutex_t lock;
    229231        link_t link;
    230232        struct answerbox *callee;
  • kernel/generic/src/ipc/ipc.c

    r10ef329a rff48a15  
    3838 */
    3939
     40#include <synch/synch.h>
    4041#include <synch/spinlock.h>
     42#include <synch/mutex.h>
    4143#include <synch/waitq.h>
    4244#include <synch/synch.h>
     
    141143void ipc_phone_connect(phone_t *phone, answerbox_t *box)
    142144{
    143         spinlock_lock(&phone->lock);
     145        mutex_lock(&phone->lock);
    144146
    145147        phone->state = IPC_PHONE_CONNECTED;
     
    150152        spinlock_unlock(&box->lock);
    151153
    152         spinlock_unlock(&phone->lock);
     154        mutex_unlock(&phone->lock);
    153155}
    154156
     
    159161void ipc_phone_init(phone_t *phone)
    160162{
    161         spinlock_initialize(&phone->lock, "phone_lock");
     163        mutex_initialize(&phone->lock);
    162164        phone->callee = NULL;
    163165        phone->state = IPC_PHONE_FREE;
     
    262264        answerbox_t *box;
    263265
    264         spinlock_lock(&phone->lock);
     266        mutex_lock(&phone->lock);
    265267        if (phone->state != IPC_PHONE_CONNECTED) {
    266                 spinlock_unlock(&phone->lock);
     268                mutex_unlock(&phone->lock);
    267269                if (call->flags & IPC_CALL_FORWARDED) {
    268270                        IPC_SET_RETVAL(call->data, EFORWARD);
     
    279281        _ipc_call(phone, box, call);
    280282       
    281         spinlock_unlock(&phone->lock);
     283        mutex_unlock(&phone->lock);
    282284        return 0;
    283285}
     
    298300        call_t *call;
    299301       
    300         spinlock_lock(&phone->lock);
     302        mutex_lock(&phone->lock);
    301303        if (phone->state == IPC_PHONE_FREE ||
    302304            phone->state == IPC_PHONE_HUNGUP ||
    303305            phone->state == IPC_PHONE_CONNECTING) {
    304                 spinlock_unlock(&phone->lock);
     306                mutex_unlock(&phone->lock);
    305307                return -1;
    306308        }
     
    321323
    322324        phone->state = IPC_PHONE_HUNGUP;
    323         spinlock_unlock(&phone->lock);
     325        mutex_unlock(&phone->lock);
    324326
    325327        return 0;
     
    450452                phone = list_get_instance(TASK->answerbox.connected_phones.next,
    451453                    phone_t, link);
    452                 if (!spinlock_trylock(&phone->lock)) {
     454                if (SYNCH_FAILED(mutex_trylock(&phone->lock))) {
    453455                        spinlock_unlock(&TASK->answerbox.lock);
    454456                        DEADLOCK_PROBE(p_phonelck, DEADLOCK_THRESHOLD);
     
    461463                list_remove(&phone->link);
    462464
    463                 spinlock_unlock(&phone->lock);
     465                mutex_unlock(&phone->lock);
    464466        }
    465467
     
    536538        printf("PHONE:\n");
    537539        for (i = 0; i < IPC_MAX_PHONES; i++) {
    538                 spinlock_lock(&task->phones[i].lock);
     540                if (SYNCH_FAILED(mutex_trylock(&task->phones[i].lock))) {
     541                        printf("%d: mutex busy\n", i);
     542                        continue;
     543                }
    539544                if (task->phones[i].state != IPC_PHONE_FREE) {
    540545                        printf("%d: ", i);
     
    561566                            atomic_get(&task->phones[i].active_calls));
    562567                }
    563                 spinlock_unlock(&task->phones[i].lock);
     568                mutex_unlock(&task->phones[i].lock);
    564569        }
    565570
     
    580585        /* Print answerbox - calls */
    581586        printf("ABOX - DISPATCHED CALLS:\n");
    582         for (tmp=task->answerbox.dispatched_calls.next;
     587        for (tmp = task->answerbox.dispatched_calls.next;
    583588             tmp != &task->answerbox.dispatched_calls;
    584589             tmp = tmp->next) {
  • kernel/generic/src/ipc/sysipc.c

    r10ef329a rff48a15  
    169169                 * not the originator
    170170                 */
    171                 spinlock_lock(&answer->data.phone->lock);
     171                mutex_lock(&answer->data.phone->lock);
    172172                spinlock_lock(&TASK->answerbox.lock);
    173173                if (answer->data.phone->state == IPC_PHONE_CONNECTED) {
     
    176176                }
    177177                spinlock_unlock(&TASK->answerbox.lock);
    178                 spinlock_unlock(&answer->data.phone->lock);
     178                mutex_unlock(&answer->data.phone->lock);
    179179        }
    180180
Note: See TracChangeset for help on using the changeset viewer.