Wi-Fi Initial Communication between device and access point

Following diagram shows the initial handshaking between the device ( like mobile ) and wireless access-point ( AP ) in open access mode and secured ( e.g. WPA ) mode, Authentication frame ( in open access ): 802.11 authentication is a process whereby the access point either accepts or rejects the identity of a radio … Read more

What is the Difference between Process and Thread ?

Creating a new thread is very similar to forking a new process, but there are differences. When a new process is forked, it shares relatively little data with the parent process which created it, when a new thread is created, it shares much more information (such as all the global variables and static local variables, … Read more

C program to check total and free RAM memory in Linux

Following C program helps you to identify what is the total and free memory / RAM available in your Linux machine. $ vim checkfreemem.c $ gcc -o checkfreemem checkfreemem.c As you can see, our program displays total RAM, Free RAM and other details. This you can corelate with Linux “free” command as,

C program to read mac address using WiFi interface name

If you need to get the mac address of certain wifi interface using C program, you can use the below program. This program should work on any Linux as well as Android platforms. $ vim read_wifi_mac.c Now, you can compile and run the program as, $ gcc -o read_wifi_mac read_wifi_mac.c $ ./read_wifi_mac

Difference between Spinlock and Semaphore

Spinlocks Spinlocks assume the data you are protecting is accessed in both interrupt-handlers and normal kernel code. If you know your data is unique to user-context kernel code (e.g., a system call), you can use the basic spin_lock() and spin_unlock() methods that acquire and release the specified lock without any interaction with interrupts. Spinlocks should … Read more

Difference between Mutex and Semaphore

Besides the better readability, the code for mutex is smaller and slightly faster than the semaphore implementation. Further, since a mutex can only be acquired by a single entity, a lot of debugging features could be added, which is otherwise not possible with the generic semaphores. And finally, the mutex semantics is less error prone … Read more

Create multiple threads, identify thread id of the current thread using pthread C library

The pthread_self() function returns the ID of the calling thread. This is the same value that is returned in *thread in the pthread_create(3) call that created this thread. The pthread_equal() function compares two thread identifiers. $ gcc -o array_of_threads array_of_threads.c -lpthread $ $ ./array_of_threads Thread -1210533056 created successfully First thread processing Thread -1218925760 created successfully Waiting in main for thread to … Read more

Creating a simple thread in Linux using pthread library api’s

$ vim simple-linux-thread-using-pthread.c The above program is self explanatory which creates a simple thread using pthread library API “pthread_create” which returns unique Thread ID in first argument threadId, and we pass two other arguments, a function pointer (functioncalledbythread) which points to the function called by the thread when it executes and void pointer which we … Read more