Changeset 2a46e10 in mainline


Ignore:
Timestamp:
2006-02-16T13:35:02Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3debedec
Parents:
ff4e1cd
Message:

Avoid memory exhaustion in thread_create in slab2 test.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • generic/src/proc/thread.c

    rff4e1cd r2a46e10  
    9696        thread_t *t = (thread_t *)obj;
    9797        pfn_t pfn;
     98        int status;
    9899
    99100        spinlock_initialize(&t->lock, "thread_t_lock");
     
    103104        link_initialize(&t->threads_link);
    104105       
    105         pfn = frame_alloc(ONE_FRAME, FRAME_KA | kmflags);
     106        pfn = frame_alloc_rc(ONE_FRAME, FRAME_KA | kmflags,&status);
     107        if (status)
     108                return -1;
    106109        t->kstack = (__u8 *)PA2KA(PFN2ADDR(pfn));
    107         if (!t->kstack)
    108                 return -1;
    109110
    110111        return 0;
     
    230231       
    231232        t = (thread_t *) slab_alloc(thread_slab, 0);
     233        if (!t)
     234                return NULL;
    232235       
    233236        /* Not needed, but good for debugging */
  • test/mm/slab2/test.c

    rff4e1cd r2a46e10  
    3535#include <mm/frame.h>
    3636#include <memstr.h>
     37#include <synch/condvar.h>
     38#include <synch/mutex.h>
    3739
    3840#define ITEM_SIZE 256
     
    116118slab_cache_t *thr_cache;
    117119semaphore_t thr_sem;
     120condvar_t thread_starter;
     121mutex_t starter_mutex;
    118122
    119123#define THREADS 8
     
    123127        void *data=NULL, *new;
    124128
     129        mutex_lock(&starter_mutex);
     130        condvar_wait(&thread_starter,&starter_mutex);
     131        mutex_unlock(&starter_mutex);
     132               
    125133        printf("Starting thread #%d...\n",THREAD->tid);
    126134
     
    173181
    174182        printf("Running stress test with size %d\n", size);
     183        condvar_initialize(&thread_starter);
     184        mutex_initialize(&starter_mutex);
     185
    175186        thr_cache = slab_cache_create("thread_cache", size, 0,
    176187                                      NULL, NULL,
     
    182193                thread_ready(t);
    183194        }
     195        thread_sleep(1);
     196        condvar_broadcast(&thread_starter);
    184197
    185198        for (i=0; i<THREADS; i++)
Note: See TracChangeset for help on using the changeset viewer.