Sunday, January 29, 2012
Friday, January 27, 2012
Tuesday, January 24, 2012
Understanding :(){ :|:& };: fork() bomb code
gets called recursively (recursive function). This is most horrible code for any Unix / Linux box. It is often used by sys admin to test user processes limitations (Linux process limits can be configured via /etc/security/limits.conf and PAM).
Once a successful fork bomb has been activated in a system it may not be possible to resume normal operation without rebooting, as the only solution to a fork bomb is to destroy all instances of it.
:() - It is a function name. It accepts no arguments at all. Generally, bash function is defined as follows:
foo(){ arg1=$1 echo '' #do_something on $arg argument }
fork() bomb is defined as follows:
:(){ :|:& };:
:|: - Next it call itself using programming technique called recursion and pipes the output to another call of the function ':'. The worst part is function get called two times to bomb your system.
& - Puts the function call in the background so child cannot die at all and start eating system resources.
; - Terminate the function definition
: - Call (run) the function aka set the fork() bomb.
Here is more human readable code:
bomb() { bomb | bomb & }; bomb
Properly configured Linux / UNIX box should not go down when fork() bomb sets off.
Saturday, January 21, 2012
Friday, January 20, 2012
Garbage Collector - concepts
rms, classic geek!
The Most Excellent and Lamentable Tragedy of Richard Stallman
http://edward.oconnor.cx/2005/04/rms
GCC guide
Must See Chapters 5,6,10,11,12,13
Thursday, January 19, 2012
CS Grads not really trained
http://www.crosstalkonline.org/storage/issue-archives/2008/200801/200801-Dewar.pdf
A professional embedded systems software engineer requires specific knowledge in a number of areas, together with problem-solving skills to apply this knowledge as a team member in building safe, secure, and reliable systems. Regrettably, says Adacore’s Robert Dewar, emeritus professor at New York University, the educational approach typically seen in university Computer Science programs, especially in the U.S., fails to provide either. Changes in course content and focus are needed.
http://www.eetimes.com/design/embedded/4238223/The-education-of-embedded-systems-software-engineers--failures-and-fixes?pageNumber=0
here is something against WEB
http://www.codinghorror.com/blog/2009/08/all-programming-is-web-programming.html
Most Programming Interviews are waste of time
References are not Addresses
Gstreamer Plugin Development(Android)
http://lca2007.linux.org.au/talk/272.html
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/part-building.html
once we are able to develop plugins for linux, we should also able to develop for android...
I managed to develop plugin for android by writing Android.mk and was able to see the boilerplate details... but still stuck up with my element registration with the plugin...
Tried to debug using remote gdb and found some memory access violation errors. Since I am using emulator... there are differences between the shared objects in emulator and in NDK.. so have to try in dev...
Wednesday, January 18, 2012
using gdbserver on android emulator
modify your Android.mk add below command "LOCAL_CPPFLAGS += -g" for C++ files and "LOCAL_CFLAGS += -G" FOR C files.
rebuild your library and system image(if necessary)
2. in your local system redirect the debug port
$ telnet localhost 5554
redir add tcp:1234:1234
exit
3.you can start emulator by below command with debug port redirected.
./emulator -avd avdname -qemu -redir udp:1234::1234
4. push gdbserver to emulator
adb push ./out/target/product/generic/obj/EXECUTABLES/gdbserver_intermediates/gdbserver /system/bin/
5. run # gdbserver :1234 --attach your-desired-pid or gdbserver :1234 desired_process
6. run ./prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-gdb ./out/target/product/generic/symbols/system/bin/app_process
7. in gdb-terminal
gdb>set solib-search-path out/target/product/generic/symbols/system/lib
In case there are multiple library paths to be searched, use ':' to concatenate the paths
gdb>target remote localhost:1234
8. Now you can see the Errors .... Happy remote Debugging!!!!
Common Error:
Malformed packet(b) (missing colon): re:0;
Packet: 'T050b:00000000;0d:c03ecebe;0f:b0070040;thread:4ab;core:0;'
This means the gdbserver and gdb in localhost are not compatible!!
Sunday, January 15, 2012
linux-android cross-compiling EGL surafce
http://jiggawatt.org/badc0de/android/
(main.c)
Here is a Android.mk file for cross compiling this with NDK
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE:=arm
LOCAL_MODULE:=mini
LOCAL_SRC_FILES:=main.c
LOCAL_MODULE_TAGS:=eng debug
LD_LIBRARY_PATH:=/home/shivram/android-ndk-r6b/platforms/android-14/arch-arm/usr/lib
LOCAL_LDLIBS:=\
-L/home/shivram/android-ndk-r6b/platforms/android-14/arch-arm/usr/lib \
-lEGL \
-ldl \
-lsurfaceflinger \
-lhardware \
-lhardware_legacy \
-lpixelflinger \
-lwpa_client \
-lemoji \
-lnetutils \
-ljpeg \
-lc \
-llog \
-lexpat \
-lskia \
-lui \
-lcutils \
-lutils \
-lbinder \
-lsurfaceflinger_client \
-lGLESv1_CM
LD:=/home/shivram/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld
LOCAL_SHARED_LIBRARIES:=\
EGL \
GLESv1_CM
LOCAL_CFLAGS := \
-DHAVE_CONFIG_H \
-I/home/shivram/android-ndk-r6b/platforms/android-14/arch-arm/usr/include \
-I/home/shivram/android-ndk-r6b/platforms/android-14/arch-arm/usr/include/EGL \
-I/home/shivram/android-ndk-r6b/platforms/android-14/arch-arm/usr/include/GLES \
-DG_THREADS_MANDATORY \
-DG_DISABLE_DEPRECATED \
-Wall \
-Wdeclaration-after-statement \
-Wvla \
-Wpointer-arith \
-Wmissing-declarations \
-Wmissing-prototypes \
-Wredundant-decls \
-Wundef \
-Wwrite-strings \
-Wformat-nonliteral \
-Wformat-security \
-Wold-style-definition \
-Winit-self \
-Wmissing-include-dirs \
-Waddress \
-Waggregate-return \
-Wno-multichar \
-Wnested-externs \
-g \
-nostdlib \
-Bdynamic \
-Wl,-dynamic-linker,/system/bin/linker \
-Wl,--gc-sections \
-Wl,-z,nocopyreloc \
-DGST_DISABLE_DEPRECATED
include $(BUILD_EXECUTABLE)
When we try to compile this.. we get... undefined reference to some pthread functions
To resolve this, the key is to write a wrapper or define those missing functions in ur (main.c) code ;)
Friday, January 13, 2012
Building GStreamer for Android
1)Best use NDKr6b(copy the platform[android-14])
2) ICS-src/bionic/linker/linker.c --> SO_MAX 128 --> +62 needed --> Maximum number of shared objects tat can be loaded at a time should be increased and Android Src must be recompiled
3)GST_REGISTRY_UPDATE=yes
4)GST_REGISTRY=/data/data/com.android.freedesktop.gstreamer/cache/registry.bin
5)GST_PLUGIN_PATH=/data/data/com.android.freedesktop.gstreamer/lib
6)GST_PLUGIN_SCANNER=/data/data/com.android.freedesktop.gstreamer/bin/gst-plugin-scanner
7) Better Copy the bins in the application to /system/bin/ with 777 permissions
After Building GST for ICS(android-14), I was able to play audio files on the device and also tried to ndk-build with proper JNI[Key: LDFLAGS:=-lX --> means load libX.so from LD_LIBRARY_PATH].....then I realised that there is no proper video sink for android in GST as it uses X-Overlay. so.....
https://wiki.linaro.org/WorkingGroups/Middleware/Multimedia/Specs/1105/GstreamerEglSink
Android NDK Build - Tutorial
http://earlence.blogspot.com/2009/07/writing-applications-using-android-ndk.html
Thursday, January 12, 2012
Linux Kernel Bootup Process
http://free-7.blogspot.com/2010/10/linux-boot-process.html
Linux Kernel Doc - Help
http://web.dit.upm.es/~jmseyas/linux/kernel/hackers-docs.html
http://www.nondot.org/sabre/os/articles
http://kernelnewbies.org/Documents/Kernel-Docbooks
Wednesday, January 11, 2012
Reset Linux passwd ~ by booting in Single User Mode
You can enter single user mode directly after turning on the power to your system. The steps to do this are listed below.
1. Power on your system. Wait for the "Grub loading" message to appear and, depending on your Linux distribution, get ready to hit either any key or the ESC key to enter the grub boot menu.
Grub loading, please wait ... Press ESC to enter the menu
or
Grub loading, please wait ... Press any key to enter the menu
2. You will then get grub's main menu which will display a list of available kernels. Use the arrow keys to scroll to your desired version of the kernel and then press e for "edit".
Fedora Core (2.6.18-1.2239.fc5smp) Fedora Core (2.6.18-1.2200.fc5smp)
3. The kernel's boot menu will appear. Use the arrow keys to scroll to the "kernel" line and then press e for "edit".
root (hd0,0) kernel /vmlinuz-2.6.18-1.2239.fc5smp ro root=LABEL=/ initrd /initrd-2.6.18-1.2239.fc5smp.img
4. A grub edit prompt will appear. Use the arrow keys to move to the end of the line and add the word "single" to the end, separated by a space. Change
grub edit> kernel /vmlinuz-2.6.18-1.2239.fc5smp ro root=LABEL=/
to
grub edit> kernel /vmlinuz-2.6.18-1.2239.fc5smp ro root=LABEL=/ single
5. Press enter to save your changes, and then b for "boot".
6. The system will continue to boot, but will go straight to the root # prompt without first asking for a username and password and now we can reset any passwd.
Basic Linux Hello World Kernel module
#include
#include
#include
static int hello_init(void)
{
printk(KERN_ALERT "Hello World");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye World");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR(RICHIE);
Step 2: vi Makefile
obj-m := hello-kernel.o
hello-kernel-objs := hello.o
Step 3: make -C /lib/modules/`uname -r`/build M=`pwd`
You should see hello-kernel.ko in your current directory, by now.
Step 4: sudo /sbin/insmod hello-kernel.ko
Step 5: dmesg
You should see "Hello World" here.
Step 6: lsmod | grep hello-kernel
Step 7: modinfo hello-kernel.ko
Step 8: sudo /sbin/rmmod hello-kernel.ko
Step 9: dmesg
You should see "Goodbye World" here.
geeksforgeeks - A Computer Science Portal
http://www.geeksforgeeks.org/
Gr8 db for C/C++ Interview qs!
http://www.geeksforgeeks.org/archives/category/linked-list
http://www.geeksforgeeks.org/archives/category/c-puzzles
http://www.geeksforgeeks.org/archives/category/gfact
http://www.geeksforgeeks.org/archives/category/tree
http://www.geeksforgeeks.org/archives/category/c-arrays
http://www.geeksforgeeks.org/archives/category/articles
Humane Computing - The beginning of a new era
"The profound technologies are those that disappear"
Machines took up different shapes and forms of real world objects by encapsulating computing prowess within them. These objects have grown in dexterity to learn and understand human behavior. We are in an era where humans have become oblivious to the existence of these computing devices. Interaction among these ubiquitous computing devices provided a platform for setting up the pervasive environment.
The potential of these environments to understand human behavior has been aided by sensors through the advancement of several technologies facilitated by gesture recognition, haptic perceptions, acoustic and phonetic analysis etc. Soft computing techniques using an agglomeration of these inputs are able to react to human behavior by the use of actuators through technologies like iO2, audio synthesis, haptic simulators etc.
The pinnacle of Humane Computing will be a time where machines would be able to understand and react to human thoughts by analyzing neuron impulses in the human brain. At that juncture it will only be a matter of time before we humans loose our hold as the most dominant species on the planet.
Divya M
Shivram R V
Sudharsan C P
V M.Sc. SWE