Explain SpinLock, SpinWait? vs lock
sl.enter/exit while(!flag {sw.Spin(100);}
Explain how Memory Barrier works?
Thread.MemoryBarrier(), Caching Optimization can move instruction around
What is Re-entrant?
How Semaphore works?
SemaphoreSlimw= new (3);_sm.Wait(); block after 3 entrer; sm.Release();
Explain InterLock.Increment/Decrement for 64-bit on 32-bit environment?
need two separate instrument InterLock.Increment(ref i);
How to use Cancellaton Token in Task?
CancelationTokenSource src. src.Token pass in
What are SynchronizationContext?
Send/Post, Dispatcher, WF/ASPNet
How do you use BlockingCollection?
How the exception in Thread handled?
WPF/WF App.DispatcherUnhandledExpcetion/ThreadExcetion UI Thread
AppDomain.Current.UnhandledException
General --Process Shutdown, Calling thread will not see it.
How to use TaskCompletionSource?
StateMachine, Task workflow, tcs.Task ReadOnly, tcs.SetResult/Cancel/Exception
How to use Parallel.For ?
Parallel.For(1,100,Action<int>)
why Binary search is O(logn)?
What is Volatile, [Thread Static] and Thread Local?
access by all thread, not optimize, each static field has its own copy, each thread has its own.
Is Lazy thread safe ?
set by 1st thread, if IsThreadSafe=true;
What is Priority Inversion?
L hold up H due to resource lock, M comes in unblocked so M>L, make L temporarity High to exec, release H
what is Thread Stavation ?
L cannot do much since H occupy.
Explain how Monitor.Pulse/Wait work?
Pulse signal to get on ReadyQueue, Wait to sit on waitQueue. vs. Enter/Exit
How to setup BeginInvoke/EndInvoke for Action?
Action a; a.BeginInvoke(new AsyncCallback(cb_f,a));
void (cb_f(IAsyncResult ar) { Action a=ar.AsyncState as Action; a.EndInvoke();}
Explain Dinning Philosopher Problem? (Minitor, Executor, Manager)
What is Mutex?
Mutex.TryOpenExisting("Name", out m); m.WaitOne(); m.ReleaseMutex();
What is Multi-cast Delegate?
D d1,d2; MuticastDelegate mcd=D.Combine(d1,d2);
How much does it cost to set up a thread?
200K CPU cycle, 1M Stack,64 bit 6 Kernal Pages, 2K cycle for Context Switching.
Explain GC and WeakReference
Reachable -- strong ref, Unreachable/FinalizerQueue =long/short weakref, 2-phase GC.
WeakReference wObj= new(TrackResurrection=true); wObj.Target is strongRef but check null needed.
What is an example of a Closure?
Func f=delegate { int i=5; i=outside var; return 5;}
Explain Syntax for Enumerable.Aggragate((acc,i)=>acc+i)
Explain UML notations of Realization/Inheritance/Aggragation/Composition/Association
Explain Design Pattern Visitor/Singleton/
What is Rx CombineLastest?
Tuesday, May 5, 2015
INTQ --Threading, C#
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment