Midterm Flashcards

1
Q

Logical address

A

Included in the machine language instructions to specify the address of an operand or instruction. Includes a segment selector and an offset.

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

Linear Address

A

A single 32-bit integer that can be used to address up to 4GB

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

Physical Address

A

Used to address memory cells in memory chips. They correspond to the electrical signals sent along the address pins of the microprocessor to the memory bus. Physical addresses are represented as 32-bit or 36-bit unsigned integers.

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

MMU

A

Turns a logical address into a linear address through the segmentation unit and a linear address to a physical address through the paging unit

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

Segmentation in hardware

A

Performs address translation in two ways: real mode and protected mode. Real mode only exists for backwards compatibility.

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

What two parts does a logical address consist of?

A

A segment identifier, and a segment offset that provides the relative address within the segment

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

What are segment registers?

A

There only purpose is to hold segment selectors(identifiers) for easy access.

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

What are the cs, ss, and ds registers used for?

A

CS: Code segment, points to segment containing program instructions. Also included a 2-bit field for the current running mode (3 for user mode, 0 for kernel mode)
SS: Stack segment, points to segment containing current running stack
DS: Data segment, points to segment containing global and static data

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

What is a segment descriptor?

A

Represents a segment and describes that segment’s characteristics

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

What are the GDT and LDT?

A

Places where segment descriptors are stored. Each program can have multiple LDTs (Local descriptor table), and there is only usually one GDT (Global descriptor table).

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

What are the nonprogrammable segmentation registers?

A

Every time a segment selector is loaded from memory, the segment descriptor is loaded into the non programmable register. That way, when transforming from logical into linear addresses, the CPU can use that register rather than looking it up in the GDT/LDT.

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

Why are using BOTH segmentation and paging redundant?

A

Segmentation can provide a linear address space to each process, while paging can map the same linear address space into different physical address spaces.

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

Why does linux prefer paging to segmentation?

A

Memory management is easier when all processes work off of the the same segment register values (that is, when they share the same linear address space). Also, implementations exist that have limited support for segmentation.

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

What are the four critical segment descriptors?

A

User code, user data, kernel code, kernel data

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

Why did linux decide to start the linear address space for all segments at 0?

A

The value of the offset field in logical addresses perfectly corresponds to linear address, and all programs, user or kernel, can use all logical addresses.

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

What happens when the CPL(current privilege level) is changed in regards to the segmentation registers?

A

The ds has to switch from the user data segment to the kernel data segment, and the cs has to switch from the user code segment to the kernel code segment. The same goes for the ss register.

17
Q

How many GDT’s are used in linux?

A

One for each CPU (so 1 in a uniprocessor system)

18
Q

How are LDT’s used in Linux?

A

The kernel defines ONE LDT to be shared by all processes. However, a program can create its own LDT if necessary (wine does, as it operates on executing windows based segments)

19
Q

What is a page?

A

A group of linear addresses in a fixed length interval. Contiguous linear address within a page are mapped to a set of contiguous physical address

20
Q

What are lightweight processes?

A

Two processes that are allowed to share some resources with each other: open files, address space, etc.

21
Q

What is a thread group?

A

All threads of a multithreaded application, and they all have the same PID (getpid returns tgid)

22
Q

Why did the Linux Kernel decide to put the thread_info field in the stack?

A

Efficiency: Through pointer operations in assembly, the current running process can be grabbed.
Multiprocessor Systems: current returns correct value for each CPU by simply looking at the stack. In earlier versions, these were defined globally in an array

23
Q

Why did Linux choose to implement doubly linked list as the data structure of choice for processes?

A

Efficiency: Can access last element in constant time AND a waste of programmers effort and memory to generate primitives for the list

24
Q

How was the runqueue changed from earlier versions of linux to 2.6 (to allow for scheduling in constant time?)

A

Instead of one run queue, there is a field in the task_struct called run_list. If a process has priority k, run_list points to a circular list containing all processes that are runnable with priority k (where k is between 0 and 139).

25
Q

Difference between API and system call

A

API offers a service, system call requires kernel service via a software trap. For example, malloc() is an API call that calls brk(), a system call.

26
Q

How are parameters passed in system calls?

A

Through CPU registers, then onto the kernel stack.

27
Q

Why is it important to verify system call parameters?

A

For memory addresses, the Kernel checks if the address is under PAGE_OFFSET so the kernel doesn’t get overwritten (a page fault exception may not occur because pages containing kernel data are loaded into RAM at boot time). Verifying that everything is in the proper address space is much too time consuming, as most programs are not faulty.

28
Q

Describe the fixup routine

A

The kernel wants to wait until it is absolutely necessary to generate an error. Therefore, it allows the paging hardware to check these conditions, using the .section .fixup method to return an error.

29
Q

How does the Linux scheduler avoid process starvation?

A

They have active processes and expired processes. Active processes are those that have not exhausted their time quantum, while expired ones have. Expired ones cannot run before all the active ones are done.