Test 3 Flashcards
Chapter 4 and 5
What is a Preprocessing Directive
Any code that begins with # #include #define #ifdef - if defined #ifndef - if not defined
What is in a Header File
- constant definitions
- data type definitions
- function prototypes (but not function implementations)
What are 4 Steps of the Compilation Process
- Preprocessing
- Assembly Code Creation
- Machine Code Creation
- Linking
What are 2 Types of Linking
Static Linking: library code copied into executable
PROS: faster execution time
CONS: larger executable size
Dynamic Linking: library code is loaded at runtime
PROS: smaller executable size
CONS: slower execution time
What is a Makefile
a text file that is used by the make command to automatically build executable programs and libraries from source code
Makefiles: how do you declare a variable
- declare at the top of the file
- e.g. OBJ = linkExample1.o linkExample2.o
- use variable with $(OBJ)
Makefiles: how do you clean?
clean:
rm -f *.o *~
What is concurrent computing
a form of computing where several computations are executed at the same time
What are the 3 main types of concurrent computing?
Multithreaded, multiple processors, and distributed systems
What is a distributed system?
a large program that is executed over multiple physical host machines that communicate via internet or intranet
What is a multi-process system?
a system running multiple processes/executables at the same time and they communicate with each other to accomplish a task
What is a multi-threaded system?
a single process with multiple control flows where multiple tasks are performed by the same CPU but they take turn sharing the CPUs resources
Name 3 common issues with concurrent computing
- Shared Resources
- Deadlocks
- Race conditions
In concurrent computing, what is the issue with shared resources? What are 2 methods for accessing shared variables?
Multiple threads or processes will likely need the same resources.
- Mutex
- Semaphore
What is a Mutex?
MUTual EXclusion object
a program object created so multiple threads can take turns using it. only the thread that locked or acquired it can unlock it
What is a Semaphore?
A variable used to control access to a common resource
It is a generalization of a Mutex
A thread waiting on a semaphore can be signalled by a different thread so that it can have access
In concurrent computing, what are deadlocks?
a condition where multiple threads/processes are blocked and all waiting for a condition that will never occur
ALWAYS DUE TO IMPROPER MUTEX/SEMAPHORE HANDLING