Subversion Repositories HelenOS-historic

Rev

Rev 772 | Rev 775 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 772 Rev 773
Line 384... Line 384...
384
 
384
 
385
/**
385
/**
386
 * Assure that the current magazine is empty, return pointer to it, or NULL if
386
 * Assure that the current magazine is empty, return pointer to it, or NULL if
387
 * no empty magazine is available and cannot be allocated
387
 * no empty magazine is available and cannot be allocated
388
 *
388
 *
-
 
389
 * Assume mag_cache[CPU->id].lock is held
-
 
390
 *
389
 * We have 2 magazines bound to processor.
391
 * We have 2 magazines bound to processor.
390
 * First try the current.
392
 * First try the current.
391
 *  If full, try the last.
393
 *  If full, try the last.
392
 *   If full, put to magazines list.
394
 *   If full, put to magazines list.
393
 *   allocate new, exchange last & current
395
 *   allocate new, exchange last & current
Line 418... Line 420...
418
        return NULL;
420
        return NULL;
419
    newmag->size = SLAB_MAG_SIZE;
421
    newmag->size = SLAB_MAG_SIZE;
420
    newmag->busy = 0;
422
    newmag->busy = 0;
421
 
423
 
422
    /* Flush last to magazine list */
424
    /* Flush last to magazine list */
423
    if (lastmag)
425
    if (lastmag) {
-
 
426
        spinlock_lock(&cache->lock);
424
        list_prepend(&lastmag->link, &cache->magazines);
427
        list_prepend(&lastmag->link, &cache->magazines);
-
 
428
        spinlock_unlock(&cache->lock);
-
 
429
    }
425
    /* Move current as last, save new as current */
430
    /* Move current as last, save new as current */
426
    cache->mag_cache[CPU->id].last = cmag; 
431
    cache->mag_cache[CPU->id].last = cmag; 
427
    cache->mag_cache[CPU->id].current = newmag;
432
    cache->mag_cache[CPU->id].current = newmag;
428
 
433
 
429
    return newmag;
434
    return newmag;