C program to find file properties using stat() function

Stat Linux

Stat() function in C is used to retrieve information about the file by accepting the filepath as an argument to it. Stat() function can help us to extract following information about any file using C program. File type and mode Number of hard links from the file User ID of file owner Group ID of … Read more

How executable is created during compilation on Linux ?

This code is tested on Ubuntu . You may need to twick the script if you use a different Linux version. The steps for compilation as as below, write a source code helloworld.c run a preprocessor which create helloworld.i run a compiler which creates helloworld.s by taking preprocessed file helloworld.i as input. run a assembler which … 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

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

What is Zombie process and How to create zombie process in Linux ?

Zombie process is the process which died immediately and whose parent didn’t cared to handled the status of child death. When a child process exits, it is not immediately cleared off the process table. Instead, a signal is sent to its parent process, which needs to acknowledge it’s child’s death, and only then the child … Read more

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. Now, you can compile and run the program as, Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by … Read more

What is Linux Out-Of-Memory OOM Killer ?

Major distribution kernels set the default value of /proc/sys/vm/overcommit_memory to zero, which means that processes can request more memory than is currently free in the system. This is done based on the heuristics that allocated memory is not used immediately, and that processes, over their lifetime, also do not use all of the memory they … Read more

How to avoid a process from being killed in case of Out of Memory ?

In our previous post, we understood “What is Out of Memory Killer ?” In this post, we tries to demonstrate how we can avoid certain process being got killed in case of OOM killer is activated due to low memory situations. How to Control which process to avoid getting Killed ? Users and system administrators … Read more

How to avoid zombie process in Linux ?

Zombie process is the process which dies/finishes immediately and whose parent didn’t cares to handle the status of child death. Such process’s continues to run in defunct state till the parent is exited completely. So this needs to be avoided, and we need to handle the status of child process properly in parent process. We … Read more