Midterm Flashcards

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?

A

6

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?

A

Signaled

25
Q

Why use _beginthreadex?

A

Thread-safe C library implementation

26
Q

What is the thread-safe C library called?

A

LIBCMT.LIB

27
Q

What needs to be done for the return type of _beginthreadex()?

A

Cast to a HANDLE type
reinterpret_cast< HANDLE >

28
Q

What are the thread states?

A

Initialized
Ready
Standby
Running
Waiting
Terminated

29
Q

What does the Sleep() function do to a thread?

A

Moves the thread from a running to a wait state

30
Q

What does the keyword volatile mean?

A

Ensures that the variable will be stored in memory after modification.

31
Q

What 2 rules apply to using the volatile keyword?

A
  1. Modified by at least one thread
  2. Accessed by two or more threads
31
Q

How do you use an interlock function to increment?

A

InterlockedIncrement()

32
Q

Which 3 synchronization objects are kernel objects?

A
  1. Mutexes
  2. Semaphores
  3. Events
33
Q

How many threads can be in a CRITICAL_SECTION at one time?

A

One

34
Q

What function is used to initialize a CRITICAL_SECTION?

A

InitializeCriticalSection()

35
Q

What function blocks a thread if another thread is in the CRITICAL_SECTION?

A

EnterCriticalSection()

36
Q

What function unblocks a waiting thread from a CRITICAL_SECTION?

A

LeaveCriticalSection()

37
Q

What is the timeout for the EnterCriticalSection() function?

A

There is no timeout

38
Q

When is a semaphore in a signalled state?

A

When the count is greater than zero.

39
Q

What does a semaphore in a signalled state signify?

A

The number in the count is the number of threads that can proceed

40
Q

How do you instantiate a mutex?

A

lock_guard< mutex >

41
Q

What does the std::thread::join method do?

A

Blocks the current thread until the thread identified finishes execution

42
Q

What does the detach() function do on a thread?

A

Thread will run independently from main thread and clean up its resources automatically after completion

43
Q

What is different about jthread?

A

Automatically joins the thread when destroyed

44
Q

What are the 3 issues with the traditional Singleton C++ implementation?

A
  1. Destructor never executes
  2. Object doesn’t initialize until referenced
  3. Not thread-safe
45
Q

What is DCLP?

A

Double Check Locking Pattern

46
Q

What are 3 alternative names for Memory Barriers?

A
  1. Membars
  2. Memory Fence
  3. Fence instruction