1/25
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is concurrency?
Concurrency is the ability of a system to have multiple tasks in progress at the same time.
Why do concurrency bugs appear only occasionally or on some platforms?
Because thread scheduling and CPU usage vary across platforms and bugs are dependent on timing and conditions.
What is a thread?
A thread is the smallest unit of execution that an operating system can schedule.
How many threads can a process contain?
A process can contain multiple threads that run concurrently
What is concurrency in the context of server implementations?
Handling multiple client requests at the same time to improve performance and responsiveness.
What is a multithreaded server?
A server that has a dedicated thread for each request
What are the advantages of multithreaded servers on physical hardware?
True parallelism on multiple cores and efficient CPU usage.
What are the disadvantages of multithreaded servers on virtualized platforms?
Not enough CPU cores, forcing threads to share them, resulting in delays and more demand for resources in thread creation
How does Node.js implement concurrency?
Using a dispatch queue to handle many requests efficiently
What are virtual threads and why are they important?
Virtual threads are lightweight threads similar to normal threads however use fewer resources so you can run lots of tasks without slowing things down.
In a virtualized environment, what is more important than raw thread count?
The ability to scale with multiple instances and efficient resource use per instance.
What is parallelism?
Where multiple threads execute independently
What is the negative impact of a deadock?
System stagnation, resource waste, downgraded performance
What can be used to prevent race conditions in Java?
synchronized keyword
What can be used to prevent deadlocks?
timeout-based locks
What keyword can ensure memory consistency for a variable without full synchronisation?
volatile
What does each CPU have it’s own of?
Cache
Which server model is better suited to physical hardware and why?
Multithreaded servers, because physical machines have multiple CPU cores that support parallelism, making thread creation and execution efficient.
Which server model works best on virtual machines (cloud platforms)?
Single-threaded servers using dispatch queues, because they use less CPU and scale easily
What is the trade-off between multithreaded and single-threaded server models?
Multithreading offers real concurrency and performance on physical servers, while single-threaded models are more efficient and scalable in virtual/cloud platforms.
What does the synchronised keyword do?
Ensures only one thread can access a block of code or object at a time.
What does the volatile keyword do?
Ensures memory consistency by ensuring all threads see the most recent value of a variable
What does a timeout-based lock do and how does it help prevent deadlocks?
It lets a thread try to get access but gives up if it takes too long. This stops threads from getting stuck and avoids deadlocks.
What’s an example of a deadlock?
Thread A holds Resource 1 and waits for Resource 2, while Thread B holds Resource 2 and waits for Resource 1
How does concurrency improve system efficiency?
It let’s the CPU do useful work while tasks are waiting instead of sitting idle.
How many conditions does it take for a deadlock to happen?
4