mm/alloc.c

alloc_mem
free_mem
del_slot
merge
max_hole
mem_init

PRIVATE struct hole {
    phys_clicks h_base;
    phys_clicks h_len;
    struct hole *h_next;
} hole [NR_HOLES];

Ein Loch besteht aus einem

  1. Anfang, Basis
  2. Länge
  3. Nächster Eintrag in der Freispeicherliste

Es gibt eine Liste mit

  1. Zeiger auf Löcher, Liste
  2. Zeiger auf unbenutzte Tabelleneinträge,
    free_slots
    

PRIVATE struct hole {
    phys_clicks h_base;
    phys_clicks h_len;
    struct hole *h_next;
} hole [NR_HOLES];

PRIVATE struct hole *hole_head;
PRIVATE struct hole *free_slots;

PUBLIC phys_clicks alloc_mem (phys_clicks clicks) {
    register struct hole *hp, *prev_ptr;
    phys_clicks old_base;


    hp = hole_head;
    while (hp != NIL_HOLE) {
        if (hp -> h_len >= clicks) {
            old_base = hp->h_base;
            hp->h_base += clicks;
            hp->h_len -= clicks;

            if (hp->h_len != 0)
                return old_base;
            del_slot (prev_ptr, hp);
            return old_base;
        }
        prev_ptr = hp;
        hp = hp->h_next;
    }
}

del_slot (struct hole *prev_ptr, struct hole *hp) {
    if (hp == hole_head)
        hole_head = hp->h_next;
    else
        prev_ptr->h_next = hp->h_next;
    hp->h_next = free_slots;
    free_slots = hp;
}

Alle funktionen des Speichers

        main
        get_work
        reply
        mm_init
        do_brk2
        set_map

        do_fork
        do_mm_exit
        mm_exit
        do_wait
        cleanup

        do_exec
        read_header
        new_mem
        patch_ptr
        load_seg

        do_brk
        adjust
        size_ok
        stack_fault

        do_signal
        do_kill
        do_ksig
        check_sig
        sig_proc
        do_alarm
        set_alarm
        do_pause
        unpause
        dump_core

        do_getset

        alloc_mem
        free_mem
        del_slot
        merge
        max_hole
        mem_init