Flashcards
ConcurrencyFull
Flashcards do conjunto (61)
- 1What is 211A drop out module lol
- 2Define Concurrency1 - Is a way on how multiple, independent processes behave when running and interacting with each other
- 3How can we use Java Threads1 - Define a class which Implements Runnable
2 - Create your objects
2 - Implementation of a run() method - 4What is a Processor1 - Device that runs instructions and can have multiple processes
- 5What is a Process and where does it reside1 - Active system entity
2 - Resides in main memory - 6What is a Program1 - Literal Application or system
2 - Program may be executed by multiple processes at the same time - 7What is the Difference between Parallel and Concurrent1 - Parallel is multiple processes executing simultaneously. All of them execute
2 - Concurrency is that multiple processes are underway and can execute at a given instant - 8What does a Scheduler guarantee and not guarantee1 - Guarantees that the code will eventually run.
2 - Doesn't guarantee fairness and timeliness.
3 - Fairness - run at the same time
4 - timeliness - complete in a desirable time frame - 9What is Safe Concurrency1 - No shared data or communication
2 - Read only data - 10What is Risky Concurrency1 - There is a shared resource and there is no synchronization
2 - A resource which can be modified by 1 or more threads - 11What is Synchronization1 - Mechanism to ensure multiple processes or threads do not simultaneously execute
- 12What is Competition1 - Competing for a variable that 2 processes want to read or update simultaneously
2 - Ensures multiple threads don't execute within the critical section - 13What is Coordination1 - One process tells another process that a result is now available
- 14What's the critical section1 - Region of code that you want protected from shared resource access
- 15What is a Race Condition1 - When more than 1 thread can access the critical section at the same time
2 - error that occurs when multiple processes are racing in an uncontrolled manner - 16What is the Difference between indeterminate and deterministic results1 - Indeterminate - We may get different results everytime
2 - Determinate - We get the same result every time - 17What is Mutual Exclusion1 - Where only one thread can run with in the critical section
- 18What is bounded waiting1 - Threads waiting to enter the section will eventually enter
2 - Threads which are in the section will eventually leave - 19What is Atomicity and a solution for this1 - Where person X and Y are writing a novel
2 - Must ensure that they do not work on the same chapter
3 - A solution could be mutual exclusion - 20What is Conditional Synchronization1 - Where one thread must finish before another thread starts
- 21Problems and solutions for concurrency management1 - Competition -> Mutex
2 - Coordination - Cond Sync - 22Define Locks1 - Mutual exclusion mechanism that limits resource access in a multi-threaded environment
- 23Name and Describe the 2 states of a Lock1 - Held - A thread is in the critical section. No one should enter
2 - Not Held - No thread is in the section. Thread can enter - 24Name and describe 2 operations of the Lock1 - Acquire - Mark the lock as held
2 - Release - mark the lock as not held - 25How can you declare a Lock1 - Like a variable
2 - Lock L - 26Where do you call Acquire and Release in the Critical section1 - Call acquire at the start of the section
2 - Call release at the end of the section - 27What is the Synchronized statement and where is it called1 - A mutual exclusion in java.
2 - Like an implicit lock
3 - used by the "synchronized" key word. eg
public void SYNCHRONIZED - 28What is Context switching1 - The idea of switching to threads and processes
RE READ THIS TOPIC.... - 29What is the 3 step context switching sequence1 - De-Schedule current thread
2 - Scheduler selects best ready thread to run using priority, time slicing
3 - Resume new selected thread - 30What is a Semaphore1 - Locks provide mutex
2 - Semaphores is the ability to have more than 1 lock.
3 - Allows multiple threads to enter the critical section - 31Why would be use semaphores and the problems that can occur1 - may want more threads or place ordering
2 - Problems such as the producer consumer problem - 32What are the operations of the semaphore1 - Wait() - Decrements the counter by 1. If the counter is at 0. No more threads can enter. Threads are put into the queue
2 - Signal() - Increments the counter by 1. - 33What happens when Wait() is called by a thread1 - If semaphore is open, continue
2 - If semaphore closed, then go to the queue - 34What happens when Signal() is called1 - If thread is on queue, then unblock it
2 - If there is no queue, then remember it for next thread - 35What are the operations of an intrinsic wait queue and what does each one do1 - Object.wait() - put thread to a stack
2 - Object.Notify() - take threads from stack and make it runnable - 36What is a Spurious Wakeup1 - Wake up all threads that you dont want to wake up
2 - Done via the NotifAll()
3 - Doesnt re-check the condition - 37What is the Producer Consumer Problem1 - producer creates
2 - Consumer will take
3 - Consumer cant take anything if nothing is there
4 - if full, stop producing
5 - if empty stop consuming - 38Define what is Message Passing1 - Type of interprocess communication
2 - Processes communicate by sending and receiving messages using primitives - 39How does Message Passing work1 - Processes communicate by sending and receiving message
- 40Define the Different channels of Message Passing1 - Local memory channel - When interacting processes are located on the same processor
2 - Physical communication - When interacting processes are located on different processors - 41What are the Primitives of Message passing1 - Send - Send message to channel - send(msg, chan)
2 - Receive - Receive a value from a channel - var = receive (chan) - 42What is the Difference between synchronous and asynchronous1 - synchronous is that the sender and receiver wait for each other
2 - asynchronous is that the sender and receiver do not wait for each other - 43What happens in a Blocking Operation in Message Passing1 - Send - blocks until message received by receiver
2 - Receive - Blocks until message is available - 44What happens in a non-blocking operations1 - Send - Process resumes with life after message is sent
2 - Receiver retrieves valid message - 45What are the problems with Synchronous1 - Reduced concurrency - When 2 processes communicate, one of them will have to block
- 46What are the problems with AsynchronousAcknowledgement - Receiver cannot know anything about state of sender.
Sender has no way of knowing if message was sent or received unless receiver replies back - 47What is a spin lock1 - Lock that keeps spinning and checking if its free or not
2 - Improves performance and CPU usage - 48What does Spin locking Violate and possible solutions for this1 - Violates mutual exclusion as there could be 2 threads with the same lock
2 - Solutions could include disable interrupts - 49What is disable interrupts1 - No context switch in critical section
2 - Really bad - 50What is a Blocking lock and advantage s and disadvantages of it1 - Scheduler blocks threads while they wait
2 - Good for long sections
3 - bad if locks are accessed a lot of time - 51What is a Spinning lock and advantage s and disadvantages of it1 - Loop a lock until acquiring
2 - Good for short section
3 - Costly for long sections - 52What is a monitor, an example of a monitor and difference between a monitor and a lock1 - Monitor can perform mutex
2 - Example of a monitor is the synchronized keyword
3 - Monitor is a construct
4 - Lock is a primitive - 53What is the Thundering Herd Problem1 - When you do notifyAll()
2 - Stampede to the section,
3 - waste of cpu cycles - 54What is a Barrier1 - Processes cannot proceed the barrier until all threads have reached the barrier
2 - How you cooperate - 55What is a Priority Based Barrier1 - Allows us to choose which thread with the highest priority can resume and proceed with the barrier
- 56What is a bounded barrier1 - The limit on the amount of threads in a barrier
- 57What is a User Thread and advantage sna disadvantages of this. What is it most useful for1 - Supported in user level library
2 - Advantage - No OS Support required
- Cheap context switch
3 - Disadvantage - cant execute on a multicore lmao
4 - useful for GUI servers and web servers - 58What is a Kernel Thread and advantage sna disadvantages of this. What is it most useful for1 - Only knows about the process, is pre emptible
2 - advantage - more concurrent
3 - disadvantage - - 59What is a deadlock, how we deal with them1 - 2 or more threads forever waiting
2 - ABBA - lock lock unlock unlock
3 - PRogram design so circular wait never occurs - 60What is a livelock1 - Process cannot make progress
2 - Livelock can be solved, - 61What is starvation1 - Process isn't getting regular access to shared resource enough
Informações
- Descrição
- FlashCards sobre ConcurrencyFull, criado por Shez F em 11-05-2017.
- Criado por
- Shez F · mai 2017
- Atualizado
- 12 mai 2017
- Visualizações
- 26
- Avaliação