Changeset 567 for trunk/kernel/mm/khm.c


Ignore:
Timestamp:
Oct 5, 2018, 12:01:52 AM (6 years ago)
Author:
alain
Message:

Complete restructuration of kernel locks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/mm/khm.c

    r551 r567  
    11/*
    2  * khm.c - kernel heap manager implementation.
     2 * khm.c - Kernel Heap Manager implementation.
    33 *
    44 * Authors  Ghassan Almaless (2008,2009,2010,2011,2012)
    5  *          Alain Greiner (2016)
     5 *          Alain Greiner (2016,2017,2018)
    66 *
    77 * Copyright (c)  UPMC Sorbonne Universites
     
    2626#include <hal_kernel_types.h>
    2727#include <hal_special.h>
    28 #include <spinlock.h>
     28#include <busylock.h>
    2929#include <bits.h>
    3030#include <printk.h>
     
    4444
    4545        // initialize lock
    46         spinlock_init( &khm->lock );
     46        busylock_init( &khm->lock , LOCK_KHM_STATE );
    4747
    4848        // compute kernel heap size
     
    7878
    7979        // get lock protecting heap
    80         uint32_t       irq_state;
    81         spinlock_lock_busy( &khm->lock, &irq_state );
     80        busylock_acquire( &khm->lock );
    8281
    8382        // define a starting block to scan existing blocks
     
    9392                if( (intptr_t)current >= (khm->base + khm->size) )  // heap full
    9493                {
    95                         spinlock_unlock_busy(&khm->lock, irq_state );
     94                        busylock_release(&khm->lock);
    9695
    9796                        printk("\n[ERROR] in %s : failed to allocate block of size %d\n",
     
    123122
    124123        // release lock protecting heap
    125         spinlock_unlock_busy( &khm->lock, irq_state );
     124        busylock_release( &khm->lock );
    126125
    127126        return (char*)current + sizeof(khm_block_t);
     
    141140
    142141        // get lock protecting heap
    143         spinlock_lock(&khm->lock);
     142        busylock_acquire(&khm->lock);
    144143
    145144        assert( (current->busy == 1) , "page already freed" );
     
    159158
    160159        // release lock protecting heap
    161         spinlock_unlock( &khm->lock );
     160        busylock_release( &khm->lock );
    162161}
    163162
Note: See TracChangeset for help on using the changeset viewer.