Think of it like being out for a hike with some friends. You agree to wait for each other at the top of each hill (and you make a mental note how many are in your group). Say you’re the first one to reach the top of the first hill. You’ll wait there at the top for your friends. One by one, they’ll arrive at the top, but nobody will continue until the last person in your group arrives. Once they do, you’ll all proceed. Barrier Synchronization works in same way.

In parallel computing, a barrier is a type of synchronization method where it enables multiple threads to wait until all threads have reached a particular point of execution(barrier) before any thread continues.
Synchronization barriers can be shared across different threads and processes. …

I’m sure you have heard word “X Macro” in C, by which you can sum up the common code of your particular section in your program. I’ve use the same concept to reduce the number of line in my (visual)code and to let computer writes code for me. Before going to example, just look at the X-macro defination.


X-Macros are based on the property of nested macros and the ability to define macros inside other macros. X-Macros are very powerful pre-processor technique in the sense that it can create a self-maintaining and inter-dependent piece of code.

Below is the code with X-Macro…

When you have a multi-threaded application, the different threads sometimes share a common resource, such as a global variable, Files or similar. This shared source often cannot be accessed at the same time, so a construct is needed to ensure that only one thread is using that resource at a time.
To make sure that this common resources are use by one thread at a time, thread library provide a MUTual EXclusive flag, Mutex.

     Lock Mutex ...
Common Resource/Critical Section
Unlock Mutex ...

Mutex acts as a gate keeper to a section of code, contain common resource, allowing one thread in and blocking access to all other thread. This ensures that the code being controled will only be hit by a single thread at a time. …

On linux, cancellation is implementated using signals. On LinuxThreads, the second real-time signal is used, if real-time signals are available, otherwise SIGUSR2 is used.
Thread cancellation lets a thread terminate the execution of any other thread in the process. This is done by pthread_cancel().

Syntax :  int pthread_cancel(pthread_t thread)Return Value : On success, it returns 0. On failure it returns Nonzero error number (ESRCH: No thread with the ID thread could be found).Description : The pthread_cancel() function sends a cancellation request to the thread. Whether and when the target thread reacts to the cancellation request depends on two attributes that are under the control of that thread: its cancelability state and type.(We’ll …

The Wiegand interface is a wiring standard used for interconnecting peripherals like fingerprint readers, card swipers or iris recognition devices to controller, Door Panels etc. The Wiegand interface is considered a de facto wiring standard for card swipe mechanisms, especially for electronic data entry.

Wiegand is:

  1. A specific reader-to-card interface
  2. A specific binary reader-to-controller interface
  3. An electronic signal carrying data
  4. The standard 26-bit binary card data format
  5. An electromagnetic effect
  6. A card technology

The Wiegand interface consists of three wires in the physical layer, the first wire is for ground and other two for data transmission, known as Data low/DATA0 and Data high/DATA1. …


Jay Desai

Embedded Software Engineer at Matrix Comsec

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store