#include<iostream>using namespace std;class PollCount{ private: int count; public: PollCount(int max_count) { cout<<"postfix unary operator (eg: a--) overloading example in c++"<<endl; count=max_count; } void disp_count() { cout<<"here is the count left->"<<count<<endl; } void operator -- (int){ if(count != 0) { count--; } else { cout<<"Access denied!!!"<<endl; } }};int main(void){ PollCount access_request(3); access_request--; access_request--; access_request.disp_count(); access_request--; access_request--;Continue reading "[C++] unary operator overloading (post fix,a–)"
[Linux-Admin]what is the maximum number of threads and processes possible
Maximum number of threads and processes possible on system wide , are stored in /proc/sys/kernel/threads-max /proc/sys/kernel/pid_max
[Linux][Driver]Fix for the error : struct i2c_device_id is not terminated with a NULL entry!
check struct i2c_device_id initialization. Missing of empty curly braces causes the error . eg: if struct i2c_device_id initialization is like given below , compiler will show the above error . ie "struct i2c_device_id is not terminated with a NULL entry! " const struct i2c_device_id adt7461_id[] = { { DRIVER_NAME, 0 }, }; Fix for the aboveContinue reading "[Linux][Driver]Fix for the error : struct i2c_device_id is not terminated with a NULL entry!"
[Linux]How to find device’s offset in linux ?
subtract KERNELBASE from the device's kernel address
[Linux]How determine a physical address from a virtual address ?
There are two ways to determine a physical address from a virtual one: va = pa + PAGE_OFFSET - MEMORY_START va = pa + KERNELBASE - PHYSICAL_START
[Linux driver]Example situation for tasklet usage
The tasklet mechanism is useful in interrupt handling situation , where the hardware interrupt must be managed as quickly as possible and most of the data management can be safely delayed to a later time.
[Linux Kernel]Tasklets vs Workqueues
In Linux, both tasklets and workqueues are ways to defer work in the kernel, but they work differently: Execution Context:Tasklets run in a software interrupt context, so all tasklet code must be atomic. Workqueues run in the context of a special kernel process, giving them more flexibility — for example, they can sleep if needed.Continue reading "[Linux Kernel]Tasklets vs Workqueues"
[Linux]A glance at data types used by kernel data
Data types used by kernel data divided into three main classes . Those arestandard C types. eg:- intexplicitly sized types . eg:- u32Interface specific types => types used for specific kernel objects . eg:- pid_t
[Linux][C]How to specify a process as the owner of the file ?
When a process invokes F_SETOWN command using fnctl system call, the process ID of the owner process is saved in filp->f_owner which can be used to address the file .Usage eg:- fd = open("/dev/filename", O_RDONLY); if (fd < 0) { fprintf(stderr, " failed to open /dev/filename \n"); return; } if ((fcntl(fd, F_SETOWN, getpid()) == 1)Continue reading "[Linux][C]How to specify a process as the owner of the file ?"
[Linux]What is Thundering herd problem in Linux point of view ?
We studied about the forms of wait_event and wake_up macros in Linux device driver text book. These macros are used to sleep the process while waiting for an event and wake up from the sleep state when even occurs .So when a process calls wake_up on a wait queue, all processes waiting on that waitContinue reading "[Linux]What is Thundering herd problem in Linux point of view ?"
[Linux][C]Which are all the file operations affected by the nonblocking flag (O_NONBLOCK) ?
The file operations affected by the non blocking flag areopenreadwrite
[Linux]A little about Timer Wheel
The original kernel timer system is known as Timer wheel.It is based on incrementing kernel- internal value (jiffie) on every timer interrupt.This timer interrupt becomes the default scheduling quantum.All the other timers are based on jiffies.
[Linux driver]A Little about put_user & __put_user
put_user and __put_user used to write the datum to user spaceFunction Declaration of put_user => put_user(datum, ptr) Function Declaration of __put_user => __put_user(datum, ptr)When single values are to be transferred, put_user/ __put_user should be called instead copy_to_user . Reason behind this is these functions(put_user/__put_user ) are relatively fast. Difference between put_user and __put_user ?put_user checks toContinue reading "[Linux driver]A Little about put_user & __put_user"
[Linux]Significance of rc.local
This script will be executed *after* all the other init scripts. We can put the customized script here, which needed to be run after system up.Also depending upon run level , there will be a local file.Like if System's runlevel is 5/etc/rc5.d/S99local is the file . There you can put the script which is to beContinue reading "[Linux]Significance of rc.local"
[Linux driver]Demonstrate Race condition in driver point of view
Lets think that the following code segment is there in the character driver code if( ! dev_ptr->data[index] ) { /*Allocate memory */ dev_ptr->data[index] = kmalloc(BUF_SIZE, GFP_KERNEL); if( ! dev_ptr->data[index] ) { goto out; } } Suppose for a moment that two processes, A and B , are independently trying to write to the same offsetContinue reading "[Linux driver]Demonstrate Race condition in driver point of view"
[Linux][Driver][C]Can we override the file operation functions in driver ?
Answer is Yes , We can override the file operation functions in driver . I wrote a character driver(hello.c) to explain the same . Also a Makefile is given to compile the hello.c file in Linux OS. An application program to test the driver also given here . Please go through it -------------------------------------------------------------------- Hello_character_driver ----------------------------------------------------------------Continue reading "[Linux][Driver][C]Can we override the file operation functions in driver ?"
[Linux driver]How to have multiple file_operations in a character driver
In the Init function of the character driver , follow the following steps Register a character driver with the file_operations structure with only open function defined . This is the selector for real open . Now create class for the module , using class_create Now create devices under this class , using device_create . EachContinue reading "[Linux driver]How to have multiple file_operations in a character driver"
[gcc]*** stack smashing detected ***
Stack Smashing is actually a protection mechanism used by gcc to detect buffer overflow attacks. An input of string greater than size defined causes corruption of gcc inbuilt protection canary variable followed by SIGABRT to terminate the program. Disabling of this gcc protection option can be done by using compiler option -fno-stack-protector
[C]Program to find whether the given machine is Little Endian or not
/*This program is to test whether the machine Little Endian or not */#include<stdio.h> #include <netinet/in.h>int main (void) {unsigned short n=0xABCD; printf (“%X %X \n”, n , ntohs(n));return 0; }compile the program .Run the program on the machine which is to be checkedIf the output isABCD CDAB then the machine is Little EndianIf the output isABCDContinue reading "[C]Program to find whether the given machine is Little Endian or not"
[U-Boot]overlapping section error in u-boot compilation
Error in u-boot compilation "section .bootpg lma 0xeffff000 overlaps previous sections" Reason - The text base address macro , CONFIG_SYS_TEXT_BASE is using default value . Solution - Define the macro CONFIG_SYS_TEXT_BASE This macro may be defined under some compiler directives. So search for this macro in the config file (eg: include/configs/board_name.h) . If it is thereContinue reading "[U-Boot]overlapping section error in u-boot compilation"
[Linux]How to compile 32-bit kernel on 64- bit machine
Include -m32 to CFLAGS variable in the Makefile eg: if there is already CFLAGS variable then CFLAGS += -m32 otherwise CFLAGS = -m32
[C]How to compile a c program for a 32 bit machine on a 64 bit machine
gcc -m32 hello.c -o hello will give 32 bit binary In order to verify the result, you can run the command file hello , which will output 32-bit LSB executable
[Shell Script]How to execute multiple shell commands using a single shell variable ?
To execute multiple shell commands using a single shell variable,Assign the multiple shell commands to a variable.execute the shell variable using echo eg:Find a.txt in the present directory Let the multiple commands are ls and grep Let the shell variable is cmd .cmd=$(ls | grep a.txt )To execute the commands ,echo $cmd cmd=$(ls | grep test.txt)
[Shell Script]How to find the total count of particular string in a file
Lets say the file name is file.txt . To find the total count of particular string , lets say "abc" , from the file.txt , execute the following command tr -s ' ' '\n' < file.txt | grep abc | wc -l Explanation of the above command tr -s ' ' '\n' -> the command trContinue reading "[Shell Script]How to find the total count of particular string in a file"
[Java]Steps to run java program in Windows
Install JDK set path environment variable for Java right click on my computer -> Advanced->Environment Variables->path Add the following in the variable value of path after putting a semicolon C:\Program Files\Java\jdk1.7.0_10\bin (or the location where JDK installed) Compiling java program compiler used for compiling java program is javac javac AbsolutePathToFile This command will create aContinue reading "[Java]Steps to run java program in Windows"
[Linux]How to change the the back ground color and writing color of the message on the Linux console
For changing background color of the message on the Linux console , please read https://ranjiniloveslinux.wordpress.com/2013/01/03/how-to-set-back-ground-color-for-the-message-on-console/For changing the writing color , please read https://ranjiniloveslinux.wordpress.com/2013/01/03/how-to-print-colorful-message-on-console/You can combine both commands to create a colorful message eg: - green writing on blue background echo -e "33[44m 33[32m Hello world"blue writing on grey background echo -e "33[47m 33[34m Hello world"
[Linux]Which process is the parent of all processes on the linux system
answer is init process. Please find the information below init is the parent of all processes on the system, it is executed by the kernel and is responsible for starting all other processes; it is the parent of all processes whose natural parents have died and it is responsible for reaping those when they die. ProcessesContinue reading "[Linux]Which process is the parent of all processes on the linux system"
[Shell Script][bash]Finding factorial of a given number using shell script
#!/bin/bash #This script will print the factorial of the number passed as arguement . eg:- ./factorial.sh 4 will print 4! value number=$1 factorial=1 i=$number while [[ $i != 1 && $i != 0 ]] do factorial=`expr $factorial \* $i` i=` expr $i - 1 ` done echo "Factorial of $number is $factorial"
[Linux]how to find physical memory of an Linux system
The physical memory is represented in /proc/kcore. The size of /proc/kcore is the same as System's physical memory, plus four bytes .
[Linux]how to see the new hardware detected in linux
You can see hardware detected by kudzu in /etc/sysconfig/hwconf.Kudzu is software from Red Hat for automatic discovery and configuration of hardware.
[Linux]How to run Red Hat Setup Agent on next boot
remove the file , /etc/sysconfig/firstbootrun chkconfig --level 5 firstboot on
[Linux]Distribution version file for Fedora, Red-Hat, Debian & Ubuntu systems
Distribution version file for Fedora -> /etc/fedora-release Red-Hat -> /etc/redhat-release Debian & Ubuntu -> /etc/debian-version In Ubuntu , distribution release details can be seen in the file , /etc/lsb-release Other distributions's version file Slackware ->/etc/slackware-version SuSe -> /etc/SuSE-release Gentoo -> /etc/gentoo-releaseContinue reading "[Linux]Distribution version file for Fedora, Red-Hat, Debian & Ubuntu systems"
[Linux][Fedora][Ubuntu] Fix for the issue “ssh connection refused “
Fedora - Install openssh-server as below sudo yum install openssh-server or if you are not in sudoer list , become root user and install openssh-server (yum install openssh-server) Ubuntu - Install openssh-server - sudo apt-get install openssh-server or if you are not in sudoer list , become root user and install openssh-server (apt-get install openssh-server)
[Linux]How to know UUID and file type of a device
UUID (Universally Unique Identifier) and file type can get from blkid(print block device attributes like filesystem type , UUID ) . You should be root user . UUID (Universally Unique Identifier) also can get from ls -l /dev/disk/by-uuid (root user)
[Linux]How to edit fstab for auto mounting hard disk partition
become root user Back up fstab (cp /etc/fstab /etc/fstab.old)fstab requires UUID (Universally Unique Identifier) of the partition , mount point and file type .UUID and file type will get by executing the command blkid (root user ) Now edit the /etc/fstab (root user) -. eg - UUID=0ABB /media/disk ntfs defaults 0 2 save the /etc/fstabReboot the system to testContinue reading "[Linux]How to edit fstab for auto mounting hard disk partition"
[Linux][C]How to add user defined include directory during compilation
User defined include directories can be added during compilation . eg: Write a simple c program #include <hello.h> int main(void) { printf("Hello world \n"); return 0; } Save the program as hello.c Now create a directory named include in your working directory . Create an hello.h inside include directory . The content of hello.h isContinue reading "[Linux][C]How to add user defined include directory during compilation"
[Linux]how to use terminal (ttyS0, ttyS1)
install minicom if minicom is not installed login as root open minicom with minicom -s select "serial port setup"change the Serial device to /dev/ttyS0 or /dev/ttyS1change baudrate to required value save setup as default and exit (not exit from minicom )
[Linux]Info about halt command
halt command in the system alias to run level 0 when you run halt command , actually “init 0″ command is executing . run level 0 is halt . halt -p -> poweroff
[Linux]how to find the commandline parameters passed to vmlinuz from linux
cat /proc/cmdline - > will show the command line arguments passed while booting linux
[Linux]mounting floppy disc on linux
check whether floppy driver module inserted in the OS by executing the following command "lsmod | grep floppy " If user is a sudoer , then follow the below steps If module is not present , insert the module by "sudo modprobe floppy " sudo udisks --mount /dev/fd0 /media/floppy0 now floppy content will be shown atContinue reading "[Linux]mounting floppy disc on linux"
[Linux]what is DAEMONS ? example for daemons
Daemons are server processes that run continuously in background, which often starts at boot time . Typically daemon names end with the letter d .Main tasks for daemon - Serve the function of responding to network requests, hardware activity, or other programs by performing some task. - Configure hardware (like udevd on linux system) - Run scheduled tasks (like cronContinue reading "[Linux]what is DAEMONS ? example for daemons"
[Fedora][Linux]How to set up static ip address on fedora
This is for fedora OS System->network->network configuration->devices->eth0->Ethernet Device->General tick the following controlled by Network manager Activate device when computer starts statically set IP addresses - update address, subnet mask , default gateway address, primary DNS and secondary DNS Also make sure that you updated ifcfg-eth0 (adding ip , net mask, gateway) in the directory (/etc/sysconfig/network-scripts)Continue reading "[Fedora][Linux]How to set up static ip address on fedora"
Did you hear about sha-bang ?
The Sha-bang (#!) at the head of a script tells Linux system that this file is a set of commands to be fed to the command interpreter indicated. Immediate following the sha-bang is a path-name eg:- #!/bin/bash Is it worth reading ? Please like the post if its helpful. Please give your suggestions too
[Fedora][Ubuntu][Linux admin]How to configure yum (in fedora) and apt-get (in ubuntu) with proxy
Steps to configure yum in fedora Edit yum.conf in /etc folder . Update proxy (eg: proxy=http://ipaddress:port) Comment baseurl in fedora.repo file in the directory, /etc/yum.repos.d Export http_proxy from terminal (export http_proxy=http://ipaddress:port). eg: http_proxy=http://192.168.100.100:80. Steps to configure apt-get in Ubuntu Create the file /etc/apt/apt.conf if not present Add the following line Acquire::http::proxy “http://ipaddress:port”; Note that ipaddressContinue reading "[Fedora][Ubuntu][Linux admin]How to configure yum (in fedora) and apt-get (in ubuntu) with proxy"
[Linux]How to compile a new kernel (2.6)
Download new kernel source code Go to the directory Do a make menuconfig if you want to build a customized kernel by enabling/disabling the modules you need make make modules make modules_install (should be root user) make install After completing this command execution, menu.lst is getting updated . Then reboot the system The system will bootContinue reading "[Linux]How to compile a new kernel (2.6)"
[Linux][Commands]Ways to check memory usage
Ways to check memory usage in Linux cat /proc/meminfo vmstat free -m
Linux Default Gateway Setup
Learn how to set a default gateway in Linux using the route command or modern ip route method. Step-by-step instructions for configuring network interfaces and IP addresses for Linux systems. sudo route add default gw <IP_ADDRESS> <INTERFACE> <IP_ADDRESS> → Replace this with the IP address of your gateway/router. <INTERFACE> → Replace this with theContinue reading "Linux Default Gateway Setup"
A window seat,a song and a quiet return
Train journey and window side seat , this combination makes my mind hum one malayalam melody song ... Pinneyum pinneyum aaro Kinaavinte Padikadannethunna padhaniswanam ... The lyrics say she repeatedly hears his footsteps coming out of her dreams... “Some journeys don’t take you closer to a place, but gently return you to a feeling youContinue reading "A window seat,a song and a quiet return"
Creativity on Wheels: My 8-Year-Old’s Amazing Bridge Build
A bridge of imagination — designed and built by an 8-year-old mind.
Ananth..
Aap se bina mulakaath karke hi Hum aap mein itna doop gayi tho phir Aap se mili tho , hai bagwaan, mein aap hi ban jaaoongi .. ~Ranjini
You arrived without knocking
Morning, morning…The only word in my mindis your name.The only face that comes to meis your face.What have you done to me?You’ve captured my mind so completely,without me ever knowingwhen it happened. ~Ranjini
Choosing Focus Over Friction
People who value professionalism understand the concept of frenemies.They may have faced past experiences, yet when a frenemy approaches with a request, they still respond in a respectful and professional manner. That doesn’t mean they are unaware or easily fooled.It simply means they choose professionalism over conflict. They’re not engaging emotionally—they’re just doing their job.Continue reading "Choosing Focus Over Friction"
“We should let go—only then can we move forward.”
Letting go is a habit I consciously practice. Instead of holding onto one issue and letting it affect my well-being, I choose to move on. This mindset has helped me both personally and professionally. But here’s something to think about:What if you moved on from a situation, evolved in your thinking, and later someone bringsContinue reading "“We should let go—only then can we move forward.”"
A Modern old folktale
"Ponmuttayidunna thaarav!" every malayalees has heard about this story once in their life time It carries a timeless lesson about human greed, impatience, and the consequences of wanting too much, too fast. Every workers got the same training and resources. But one person,Anand, showed excellence for years. some new faces came and some faces fadedContinue reading "A Modern old folktale"
The Lamp in the Workshop
Credit:Chatgpt In a large workshop, there once worked a skilled craftsperson known for precision and honesty. Whenever a machine failed or a process became confusing, people quietly gathered around this person’s table. Problems were explained, mistakes were corrected, and work moved forward smoothly again. The craftsperson never refused to help. Knowledge, after all, was meantContinue reading "The Lamp in the Workshop"
When dreams walk with you
Dreams of early-morning walks with you Imagination of that reflection moments of us Making me to wish the dreams should come true. ~Ranjini