Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset e5f5ce0 in mainline


Ignore:
Timestamp:
2017-09-04T20:25:18Z (3 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
9e87562
Parents:
431c402
Message:

Create a slab cache for allocating phone_t structures

Location:
kernel/generic
Files:
3 edited

Legend:

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

    r431c402 re5f5ce0  
    4242#include <abi/proc/task.h>
    4343#include <typedefs.h>
     44#include <mm/slab.h>
    4445
    4546struct answerbox;
     
    166167} call_t;
    167168
     169extern slab_cache_t *phone_slab;
     170
    168171extern answerbox_t *ipc_phone_0;
    169172
  • kernel/generic/src/ipc/ipc.c

    r431c402 re5f5ce0  
    6666answerbox_t *ipc_phone_0 = NULL;
    6767
    68 static slab_cache_t *ipc_call_slab;
    69 static slab_cache_t *ipc_answerbox_slab;
     68static slab_cache_t *call_slab;
     69static slab_cache_t *answerbox_slab;
     70
     71slab_cache_t *phone_slab = NULL;
    7072
    7173/** Initialize a call structure.
     
    9597                if (call->buffer)
    9698                        free(call->buffer);
    97                 slab_free(ipc_call_slab, call);
     99                slab_free(call_slab, call);
    98100        }
    99101}
     
    112114call_t *ipc_call_alloc(unsigned int flags)
    113115{
    114         call_t *call = slab_alloc(ipc_call_slab, flags);
     116        call_t *call = slab_alloc(call_slab, flags);
    115117        if (call) {
    116118                _ipc_call_init(call);
     
    201203int ipc_call_sync(phone_t *phone, call_t *request)
    202204{
    203         answerbox_t *mybox = slab_alloc(ipc_answerbox_slab, 0);
     205        answerbox_t *mybox = slab_alloc(answerbox_slab, 0);
    204206        ipc_answerbox_init(mybox, TASK);
    205207       
     
    209211        int rc = ipc_call(phone, request);
    210212        if (rc != EOK) {
    211                 slab_free(ipc_answerbox_slab, mybox);
     213                slab_free(answerbox_slab, mybox);
    212214                return rc;
    213215        }
     
    256258        assert(!answer || request == answer);
    257259       
    258         slab_free(ipc_answerbox_slab, mybox);
     260        slab_free(answerbox_slab, mybox);
    259261        return rc;
    260262}
     
    854856void ipc_init(void)
    855857{
    856         ipc_call_slab = slab_cache_create("call_t", sizeof(call_t), 0, NULL,
     858        call_slab = slab_cache_create("call_t", sizeof(call_t), 0, NULL,
    857859            NULL, 0);
    858         ipc_answerbox_slab = slab_cache_create("answerbox_t",
    859             sizeof(answerbox_t), 0, NULL, NULL, 0);
     860        phone_slab = slab_cache_create("phone_t", sizeof(phone_t), 0, NULL,
     861            NULL, 0);
     862        answerbox_slab = slab_cache_create("answerbox_t", sizeof(answerbox_t),
     863            0, NULL, NULL, 0);
    860864}
    861865
  • kernel/generic/src/ipc/ipcrsc.c

    r431c402 re5f5ce0  
    208208        int handle = cap_alloc(task);
    209209        if (handle >= 0) {
    210                 phone_t *phone = malloc(sizeof(phone_t), FRAME_ATOMIC);
     210                phone_t *phone = slab_alloc(phone_slab, FRAME_ATOMIC);
    211211                if (!phone) {
    212212                        cap_free(TASK, handle);
     
    248248        assert(phone->state == IPC_PHONE_CONNECTING);
    249249       
    250         free(phone);
     250        slab_free(phone_slab, phone);
    251251        cap_free(TASK, handle);
    252252}
Note: See TracChangeset for help on using the changeset viewer.