Quiz Flashcards

1
Q

Linux memory area

A
  • a chunk of virtual memory mapped to a VM area space structure
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

task_struct

A
  • The OS stores process state in a data structure called process control block. There is one per process
    called task_struct in linux
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

mm_struct

A

kernel’s representation of a process’s address space
important fields:
-mm_users = # of processes using the address space
-mm_count = main reference count; when the kernel operates on an address space, it bumps up the reference counter. all users = 1 count
-mmap and mm_rb: contain all the memory areas in this address space
pgd_t *pgd: physical address of the first thing in the pgd??? do we add the PGD offset to the start address of the PGD?

all of the mm_struct structures of every process are strung together in a doubly linked list via the mmlist field

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

vm_area_struct

A

describes a single memory area over a CONTIGUOUS VIRTUAL ADDRESS INTERVAL in a given address space
each VMA possesses certain permissions and associated operations
each VMA structure can represent different types of memory areas

important struct fields:
-VMA start (lowest address in the interval)
-vm_end (first byte AFTER the highest address in the interval)
length in bytes of memory area = vm_end - vm_start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

pgd

A

the page global directory (pgd) which consists of an array of pgd_t types. The entries in the pgd point to entries in the second level directory, the PMD. The second-level page table is the page middle directory (PMD), which is an array of pmd_t types. Entries in the PMD point to entries in the PTE. Final level = page table; consists of page table entries of type pte_t. Page table entries point to physical pages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Difference between segmentation fault and protection fault?

A
  • segmentation fault occurs when request and address is not in the VMA
  • protection fault occurs when you don’t have permissions to access that address
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

memory mapping

A
  • structure of data indicating how memory is laid out
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

anonymous file

A

a temporary file without a descriptor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

swap file (swap space)

A
  • portion of the memory used for virtual memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

shared object

A
  • a file that contains binary code and data that can be loaded into memory and linked dynamically
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

shared area

A
  • virtual memory that are shared by more than one process and then can be used by multiple programs simultaneously. Although virtual memory allows processes to have separate address spaces, there are times when you need processes to share memory.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

copy-on-write

A
  • copy file and save new only when wrote to otherwise access the same file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

dynamic memory allocator

A

Maintains an area of a process’s virtual memory, known as heap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

allocated memory

A
  • allocated memory is memory that is filled
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How does the VM system used for the execve function?

A

The shell stores the environment in memory and passes it to the execve() system call. The child process inherits it as an array pointer called environ

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the mmap function do?

A
  • allows you to comb through a file like it is an array. Asks the kernel to create a new virtual memory area
17
Q

implicit allocator

A
  • implicit allocators implicitly allocates memory

- does not free the space

18
Q

What does malloc do when it cannot satisfy a memory request?

A
  • it returns a NULL
19
Q

How does free work?

A

It accepts a pointer as its parameter. The free command does two things: The block of memory pointed to by the pointer is unreserved and given back to the free memory on the heap. It can then be reused by later new statements.

20
Q

Throughput

A
  • how many commands per second
21
Q

aggregate payload

A
  • this is all the payloads added together
22
Q

internal fragmentation

A
  • type of fragmentation where the payload is smaller than the block size it is going into
23
Q

external fragmentation

A
  • type of fragmentation where the payload…space cannot be filled
  • to explain more the area that is free in the block cannot be filled by the payload
24
Q

Why use dynamic memory allocation?

A

When you need a lot of memory. Typical stack size is 1 MB, so anything bigger than 50-100KB should better be dynamically allocated, or you’re risking crash. Some platforms can have this limit even lower.

When the memory must live after the function returns. Stack memory gets destroyed when function ends, dynamic memory is freed when you want.

When you’re building a structure (like array, or graph) of size that is unknown (i.e. may get big), dynamically changes or is too hard to precalculate. Dynamic allocation allows your code to naturally request memory piece by piece at any moment and only when you need it. It is not possible to repeatedly request more and more stack space in a for loop.

25
Q

Requirements for explicit allocators? (5)

A
Handling arbitrary request sequences
Making immediate responses to requests
Using only the heap
Aligning Blocks
Not modifying allocated blocks
26
Q

Utilization

A
  • how much memory is being used; virtual memory is not an unlimited resource
27
Q

free-block organization

A

How do we keep track of free blocks?

28
Q

Peak utilization

A
  • maximum utilization
29
Q

block splitting

A

After we place a newly allocated block in some free block, what do we do with the remainder of the free block?

30
Q

block coalescing

A

What do we do with a block that has just been freed?

31
Q

payload

A

the actual space an application requested when it called malloc

32
Q

padding

A

Unused and can be any size; might be part of an allocator’s strategy for combating external fragmentation, OR satisfying the alignment requirement

33
Q

demand-zero page

A

a physical page of all 0s

34
Q

How is the COW mechanism used for the fork function?

A

when a fork occurs, the parent process’s pages are not copied for the child process. Instead, the pages are shared between the child and the parent process.