Month: November 2017

Linux – Handling Signals in a Multithreaded Application

Signals are very useful feature in linux to send notification from one process to another and from the kernel to the process. Signals are sent in some error cases (accessing wrong memory address, bus error, floating point error, …) and also to inform the user application (timer expired, child process finished, IO is ready, ….) […]

Read more

Python Multitasking – MultiThreading and MultiProcessing

Modern operating systems allow a user to run several applications simultaneously, so that some tasks can be run in the background while the user continues with other work in the foreground. The user can also run multiple copies of the same program at the same time. To create a task we can use process or […]

Read more

Python Machine Learning Example – Linear Regression

In my previous post, I went over the basic concepts in machine learning and I used a very small amount of data. I got great feedbacks but also notes to make more complex example with bigger dataset. In this post I will use a bigger dataset and use pandas , seaborn and scikit-learn to illustrate […]

Read more

Android ION

One of the features google added to linux kernel is a general purpose allocator /dev/ion. The new allocator allows us to allocate memory from different heaps and devices, virtual and physical User space usage #include<stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/mman.h> #include “/home/developer/kernel3.4/goldfish/include/linux/ion.h” void main() { int *p; struct ion_fd_data fd_data; […]

Read more

Understanding Linux Kernel Preemption

While configuring a Linux kernel, we can set some parameters that effect the system behavior. You can work with different priorities, scheduling classes and preemption models. It is very important to understand and choose the right parameters. In this post I will cover the different preemption models and how does each one effect the user and […]

Read more

Creating a Java VM from Native code

On Android init phase we are running init application that uses its init scripts to start all the code system services. We can add a new daemon easily if we are building a ROM by add an empty folder, adding Android.mk file and C/C++ source file. In this way we can run C/C++ code but […]

Read more

Linux Control Groups

Using cgroups you can limit resource usage of processes , for example if you have a web server and you want limit its memory usage to 1GB its very easy to do with cgroups. This is also a basic building block for containers First we need to install some tools (in my example im using […]

Read more

Creating a Linux bridge

A network bridge helps you connect 2 different networks with the same characteristics (Ethernet for example). Its very easy to implement it in linux using some tools Example We run Qemu  image with tap interface – we can connect from the qemu image to the linux host but we cant access the entire network (internet) […]

Read more

10 Python Interview Questions You need to know

Python is very popular programming language with many job offers. I collected some questions (with answers) from many students interviews. Test yourself: are you ready to work with python? 1. Base and derived classes: Look at the following code: class A(object): def show(self): print ‘base show’ class B(A): def show(self): print ‘derived show’ obj = […]

Read more

Java and C/C++: JNI Guide

While writing Android application or other generic java application you sometimes need to write code in C/C++. Java is a dynamic language with a lot of security checks for example on every array access, every type cast , on function call and return and more. those checks affect performance and if you want to manipulate […]

Read more