Week 8 - Jumps Flashcards

1
Q

What does jmp mean?

A

Unconditional jump

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

What does jg mean?

A

Jump if greater

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

What does goto do?

A

Unconditionally jumps to a labelled statement

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

Write an example goto statement.

A

label:

<statements>
goto label;
</statements>

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

Why is goto considered harmful?

A

Because the flow of control in code is not clear

Spaghetti code is difficult to read and maintain

All programming constructs can be written without jumps

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

What does the state of an executing program depend on?

A

Virtual address space:
- code (the executing program code)
- data/BSS (static variables)
- stack (function return address, parameters, auto variables)
- heap (dynamically allocated variables)

Registers, including:
- sp (stack pointer)
- bp (base pointer)
- pc (program counter)

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

What does setjmp do?

A

Saves the contents of the registers to a buffer

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

What does longjmp do?

A

Restores the contents of the registers from a buffer

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

What is the difference between concurrency and parallelism?

A

Concurrency is multiple processes accessing one disk and sharing one CPU (with time slicing and context switching)

Parallelism is multiple processes running on separate CPUS

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

Are coroutines concurrent and/or parallel?

A

They are concurrent but not parallel

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

Give an example usage for coroutines.

A

Computer games to maintain an high framerate as the program can switch between the coroutine and the game loop

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