Changeset 9e87562 in mainline for kernel/generic/src/ipc/ipcrsc.c


Ignore:
Timestamp:
2017-09-18T20:52:12Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6abfd250
Parents:
e5f5ce0
Message:

Make all accesses to capabilites exclusive

This commit makes sure that all accesses to the capabilities array and other
metadata are protected by a mutex. This is necessary for future resizing of the
capabilities array.

Group task's capabilities by type so that it is possible to visit all
capabilities of the given type effectively.

Provide cap_publish() and cap_unpublish() to automate steps that make the
capability visible/invisible to userspace and insert/remove the capability from
the respective type list.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ipcrsc.c

    re5f5ce0 r9e87562  
    175175phone_t *phone_get(task_t *task, int handle)
    176176{
     177        phone_t *phone;
     178
     179        caps_lock(task);
    177180        cap_t *cap = cap_get(task, handle, CAP_TYPE_PHONE);
     181        phone = (phone_t *) cap->kobject;
     182        caps_unlock(task);
    178183        if (!cap)
    179184                return NULL;
    180185       
    181         return (phone_t *) cap->kobject;
     186        return phone;
    182187}
    183188
     
    217222                phone->state = IPC_PHONE_CONNECTING;
    218223               
    219                 irq_spinlock_lock(&task->lock, true);
     224                // FIXME: phase this out eventually
     225                mutex_lock(&task->cap_info->lock);
    220226                cap_t *cap = cap_get(task, handle, CAP_TYPE_ALLOCATED);
    221                 cap->type = CAP_TYPE_PHONE;
    222                 cap->kobject = (void *) phone;
    223227                cap->can_reclaim = phone_can_reclaim;
    224                 irq_spinlock_unlock(&task->lock, true);
     228                mutex_unlock(&task->cap_info->lock);
     229
     230                cap_publish(task, handle, CAP_TYPE_PHONE, phone);
    225231        }
    226232       
     
    237243void phone_dealloc(int handle)
    238244{
    239         irq_spinlock_lock(&TASK->lock, true);
    240         cap_t *cap = cap_get_current(handle, CAP_TYPE_PHONE);
     245        cap_t *cap = cap_unpublish(TASK, handle, CAP_TYPE_PHONE);
    241246        assert(cap);
    242         cap->type = CAP_TYPE_ALLOCATED;
    243         irq_spinlock_unlock(&TASK->lock, true);
    244247       
    245248        phone_t *phone = (phone_t *) cap->kobject;
Note: See TracChangeset for help on using the changeset viewer.