Justines Section Flashcards
What is override?
Overrides a base class’s method with its own implementation. (Not needed but is good practice)
What is virtual keyword?
When a function is declared as virtual it indicates that it can be overridden by a derived class. (Is needed)
What is method overloading?
Creating multiple methods in a class with the same name but different signatures.
What is a struct?
Similar to a class but accessible to public access.
What is a ring buffer?
A memory buffer that acts like a loop.
What is a process?
A process is an executing program that an operating system uses to separate applications.
What is a Thread?
The basic unit of processor allocation and execution within a process.
What is used to merge threads together once they are finished?
.join()
What is a lambda function?
An anonymous function with no name containing short snippets of code that wont be reused.
What makes up a lambda function?
- (parameters): Parameters of the function
- –> return type
- {} method
What is the effect of passing by reference?
Allows all threads to modify the parameter. Just use ref()
What is a race condition?
An unpredictable ordering of events where some orderings may cause undesired behaviour.
What is Atomicity?
property of an operation to be executed as a single, indivisible unit without interference from other concurrent operations.
What is a mutex?
A type of lock that locks a section of code till it completes then unlocks it.
What is deadlock?
The situation where a thread or threads rely on a mutually blocked resource that will never become available.
How does a lock guard work?
It locks a lock in its constructor and unlocks it in its destructor automatically unlocking when the lock guard goes out of scope.
How does a condition variable differ from a mutex?
It can be shared across threads and used for one thread to notify other threads when something happens. A thread can also use this to wait until it is notified.
What is a semaphore?
A variable that lets you manage a count of finite resources. The count is incremented by calls to release and decremented by calls to acquire.
How can a deadlock be prevented?
1) By always locking mutexes in the same order
2) By using std::lock to automatically lock multiple mutexes
3)By avoiding circular wait conditions
What is a spurious wakeup in C++ multithreading?
A situation when a thread wakes up randomly without being notified.
What is function overloading?
The ability to define multiple functions with the same name but different parameter lists within the same scope.