diff --git a/W11D2/note_liu_yiyu.md b/W11D2/note_liu_yiyu.md new file mode 100644 index 0000000..1ea89ad --- /dev/null +++ b/W11D2/note_liu_yiyu.md @@ -0,0 +1,32 @@ +# MULTI-core/processor/computer + +SMC/SMP/cluster/Grid/Cloud... + +multi: shared memory, multi-CPU + +UMA-NUMA + +multiple spinlock, bus + +- Avoid cache thrashing! +- Time sharing, the art of scheduling + +"Gang scheduling" : A gang of related threads are scheduled as a unit, a "gang" + +"Computational Graph": ->"A platform for ML" + +"Distributed Shared Memory": Like page table, with indices + +## Graph computing + +relations between Nodes, allocation of resources,... + +GraphChi + +Speed up executing, space less, locality is good. + +And we have algorithms. + +Object-based middleware "**CORBA**" + +Based on CORBA. Distributed systems. diff --git a/W3D2/note_liu_yiyu.md b/W3D2/note_liu_yiyu.md new file mode 100644 index 0000000..b6745de --- /dev/null +++ b/W3D2/note_liu_yiyu.md @@ -0,0 +1,48 @@ +# Process & Thread + +## Sync + +### Lock, Mutex and Semaphore + +Race condition + +Semaphore by Dijkstra + +- need a counter +- a waiting queue (either kernel or user) +- maybe two locks (mutex and a flag/slot) +- order (as a stack) + +Mutex +```c +pthread_mutex_lock(&mutex); +pthread_cond_wait(&cond, &mutex); +``` + +The second line is to avoid sleep with a mutex locked and to make it possible for the consumer to wake it. + +### Monitor + +To design a sync function in language level. + +Avoid the problem caused by a breaking change in architecture + +### Memory Barrier + +To make sure the consistency + +- Before this statement, no matter what the order is (for multi-thread), nothing happened. +- After this statement, ... +- But the statements after this statement cannot be executed before the memory barrier. And vice versa. + +### Thread Scheduling + +For a scheduler, it should determine who is next. + +Algorithm: +- RR +- O(1): In O(1) time complexity +- Staircase Down +- RSDL +- CFS +- Brain Fuck diff --git a/W7D2/note_liu_yiyu.md b/W7D2/note_liu_yiyu.md new file mode 100644 index 0000000..abb26d7 --- /dev/null +++ b/W7D2/note_liu_yiyu.md @@ -0,0 +1,24 @@ +# Dead Lock + +## Conditions + +1. Mutual exclusion +1. Hold and wait +1. No preemption +1. Circular wait condition + +## Solution + +- Don't care! +- Detection and recovery. Let deadlocks occur, detect them, and then take action. +- Dynamic avoidance by careful resource allocation. +- Prevention, by structurally negating one of the four required conditions. + +### Detection + +Banker's algorithm + +### Avoiding + +- Resource Trajectories +- In numeric order