Midterm Flashcards

(47 cards)

1
Q

What is the minimum number of threads in a process?

A

One

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

What is the basic executable unit in Windows?

A

Thread

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

TLS

A

Thread Local Storage

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

What is Thread Local Storage?

A

A collection of pointers for a thread to allocate storage

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

What function is used to create a process?

A

CreateProcess()

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

How many threads does the CreateProcess() function create?

A

One

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

How many parameters does CreateProcess() have?

A

10

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

What is the return type of CreateProcess()?

A

Bool

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

What object has the handles for the thread and process after CreateProcess() runs?

A

PROCESS_INFORMATION

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

Does CloseHandle() terminate the thread?

A

No, it only deletes the reference within the process

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

What two things are returned for both the thread and the process created using CreateProcess()

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

Each process/thread has a unique ______ for the lifetime of the object, but can have many ______.

A

ID, Handles

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

If ApplicationName parameter is set to NULL in CreateProcess(), what will the program name be?

A

The first white-space-deliminated token in CommandLine

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

What function does a thread in a process use to terminate the process?

A

ExitProcess()

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

What function does a process use to terminate a different process?

A

TerminatePocess()

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

What are the 2 wait functions?

A
  1. WaitForSingleObject()
  2. WaitForMultipleObjects()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the maximum number of wait objects for WaitForMultipleObjects() function?

A

64

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

What data type are the times returned from GetProcessTimes()?

A

FILETIME

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

How many parameters does the CreateThread() function take?

20
Q

What is the thread function signature?

A

DWORD WINAPI ThreadFunc (LPVOID)

21
Q

What can the thread interpret the argument passed to the thread function as?

A

DWORD or Pointer

22
Q

How do you create a thread that doesn’t start immediately after creation?

A

dwCreationFlags = CREATE_SUSPENDED

23
Q

How do you start a suspended thread?

A

ResumeThread()

24
Q

What state does the wait function wait for from the object?

25
Why use _beginthreadex?
Thread-safe C library implementation
26
What is the thread-safe C library called?
LIBCMT.LIB
27
What needs to be done for the return type of _beginthreadex()?
Cast to a HANDLE type reinterpret_cast< HANDLE >
28
What are the thread states?
Initialized Ready Standby Running Waiting Terminated
29
What does the Sleep() function do to a thread?
Moves the thread from a running to a wait state
30
What does the keyword volatile mean?
Ensures that the variable will be stored in memory after modification.
31
What 2 rules apply to using the volatile keyword?
1. Modified by at least one thread 2. Accessed by two or more threads
31
How do you use an interlock function to increment?
InterlockedIncrement()
32
Which 3 synchronization objects are kernel objects?
1. Mutexes 2. Semaphores 3. Events
33
How many threads can be in a CRITICAL_SECTION at one time?
One
34
What function is used to initialize a CRITICAL_SECTION?
InitializeCriticalSection()
35
What function blocks a thread if another thread is in the CRITICAL_SECTION?
EnterCriticalSection()
36
What function unblocks a waiting thread from a CRITICAL_SECTION?
LeaveCriticalSection()
37
What is the timeout for the EnterCriticalSection() function?
There is no timeout
38
When is a semaphore in a signalled state?
When the count is greater than zero.
39
What does a semaphore in a signalled state signify?
The number in the count is the number of threads that can proceed
40
How do you instantiate a mutex?
lock_guard< mutex >
41
What does the std::thread::join method do?
Blocks the current thread until the thread identified finishes execution
42
What does the detach() function do on a thread?
Thread will run independently from main thread and clean up its resources automatically after completion
43
What is different about jthread?
Automatically joins the thread when destroyed
44
What are the 3 issues with the traditional Singleton C++ implementation?
1. Destructor never executes 2. Object doesn't initialize until referenced 3. Not thread-safe
45
What is DCLP?
Double Check Locking Pattern
46
What are 3 alternative names for Memory Barriers?
1. Membars 2. Memory Fence 3. Fence instruction