Session 6: Kernel: Some bits of memory

Tasks

Download and unzip the tasks archive sesiune-06 on the virtual machine.

  1. Memory limits (1)
    • Use the code in 1-mem/ directory and figure out the maximum chunk size that can be allocated using kmalloc.
    • Start by allocating a chunk of size 1K, and double the memory allocated at each iteration. Stop when kmalloc fails.
  2. Memory limits (2)
    • Use the code in 1-mem/ directory and figure out the maximum amount of memory that can be allocated in tne system.
    • Allocate memory chunks of 1K until the system gets Out of Memory.
  3. Memory caches
    • Check the code in 2-cache/ directory and see how memory caches are created. Following the example from cache.c allocate 2048 penguin objects.
    • Analyze the output for the following commands slabtop and cat /proc/slabinfo in respect with penguin structure.
  4. The curse of sleeping
    • Use the skeleton code from 3-context/ and fill in the code in context.c so that:
      • use kmalloc function with GFP_KERNEL flag, protect the allocation using a spin_lock.
      • use kmalloc function with GFP_ATOMIC flag, protect the allocation using a spin_lock.
      • replace kmalloc function with schedule_timeout.
  5. Memory mappings
    • Use the skeleton code from 4-mmap/ and fill in the code in kmmap.c so that:
      • /dev/mmap has support for memory mapping
      • Implement function my_map in kmmap.c. Use mmap as an example.
      • Follow TODO's lines in kmmap.c
    • Create an userspace program mmap.c that mmaps /dev/my_mmap and reads a page.
    • Check mmap.c memory mapped areas using pmap.
sesiuni/kernel/memory.txt · Last modified: 2012/07/09 01:06 by dbaluta