cpp template zip file:
google link here
Saturday, April 21, 2018
Friday, April 20, 2018
C++ class layout
class layout
https://www.evernote.com/shard/s260/sh/dfc7453b-e50f-46c0-b223-196bead364a9/c41f1cea8f38c1802d1941338b03d375
vtable:
https://en.wikipedia.org/wiki/Virtual_method_table
https://www.evernote.com/shard/s260/sh/dfc7453b-e50f-46c0-b223-196bead364a9/c41f1cea8f38c1802d1941338b03d375
vtable:
https://en.wikipedia.org/wiki/Virtual_method_table
using CAS to implyment spinlock
#define CAS __sync_bool_compare_and_swap
bool __sync_bool_compare_and_swap (type *ptr, type oldval type newval, ...) __sync_val_compare_and_swap (type *ptr, type oldval type newval, ...)*ptr is oldval, then write newval into *ptr.The “bool” version returns true if the comparison is successful and newval was written. The “val” version returns the contents of *ptr before the operation.
static inline void my_spinlock(unsigned int *lock){while (!CAS(lock, 0, 1));}static inline void my_spinunlock(unsigned int *lock) { *lock = 0;//CAS(lock, 1, 0);}
Tuesday, April 17, 2018
Esxi patch update
Esxi patch update:
esxcli software vib update -d /vmfs/volumes/5a023555-73045df5-66c5-0090fb60192a/ESXi650-201803001.zip
Tuesday, April 10, 2018
IRQL
What is IRQL and why is it important?
Interrupt Request Levels – aka IRQL’s. If you develop device drivers or spend a lot of time debugging, IRQL’s are familiar territory for you. An interrupt request level (IRQL) defines the hardware priority at which a processor operates at any given time. In the Windows Driver Model, a thread running at a low IRQL can be interrupted to run code at a higher IRQL. The number of IRQL’s and their specific values are processor-dependent.
Processes running at a higher IRQL will pre-empt a thread or interrupt running at a lower IRQL. An IRQL of 0 means that the processor is running a normal Kernel or User mode process. An IRQL of 1 means that the processor is running an Asynchronous Procedure Call (APC) or Page Fault. IRQL 2 is used for deferred procedure calls (DPC) and thread scheduling. IRQL 2 is known as the DISPATCH_LEVEL.
When a processor is running at a given IRQL, interrupts at that IRQL and lower are blocked by the processor.
Therefore, a processor currently at DISPATCH_LEVEL can only be interrupted by a request from an IRQL greater than 2. A system will schedule all threads to run at IRQL’s below DISPATCH_LEVEL – this level is also where the thread scheduler itself will run. So if there is a thread that has an IRQL greater than 2, that thread will have exclusive use of the processor. Since the scheduler runs at DISPATCH_LEVEL, and that interrupt level is now blocked off by the thread at a higher IRQL, the thread scheduler cannot run and schedule any other thread. So far, this is pretty straightforward – especially when we’re talking about a single processor system.
When a processor is running at a given IRQL, interrupts at that IRQL and lower are blocked by the processor.
Therefore, a processor currently at DISPATCH_LEVEL can only be interrupted by a request from an IRQL greater than 2. A system will schedule all threads to run at IRQL’s below DISPATCH_LEVEL – this level is also where the thread scheduler itself will run. So if there is a thread that has an IRQL greater than 2, that thread will have exclusive use of the processor. Since the scheduler runs at DISPATCH_LEVEL, and that interrupt level is now blocked off by the thread at a higher IRQL, the thread scheduler cannot run and schedule any other thread. So far, this is pretty straightforward – especially when we’re talking about a single processor system.
On a multi-processor system, things get a little complicated. Since each processor can be running at a different IRQL, you could have a situation where one processor is running a driver routine (Device Interrupt Level – aka DIRQL), while another processor is running driver code at IRQL 0. Since more than one thread could attempt to access shared data at the same time, drivers should protect the shared data by using some method of synchronization. Drivers should use a lock that raises the IRQL to the highest level at which any code that could access the data can run. We’re not going to get too much into Locks and Deadlocks here, but for the sake of our discussion, an example would be a driver using a spin lock to protect data accessible at DISPATCH_LEVEL. On a single processor system, raising the IRQL to DISPATCH_LEVEL or higher would have the same effect, because the raising of the IRQL prevents the interruption of the code currently executing.
That will actually wrap it up for this post. It’s a fairly short post, but hopefully you now have a basic understanding of IRQL. Until next time …
Wednesday, March 21, 2018
Tuesday, March 13, 2018
copy/paste with mouse for tmux on mac
To restore the default copy/paste configuration you need to (at least temporarily) turn off mouse support within tmux:
prefix : set -g mouse off
Where
prefix is the tmux access key (Ctrl+B by default unless you re-map it). : starts command mode and set -g sets the parameter globally.
Subscribe to:
Posts (Atom)
