Wednesday, April 15, 2015

How Linux Memory is Managed - Part 1

To make virtual memory concept simple, we need to remember few basic ground rules.

1. Linux visualizes its physical resource of memory
2. Process never ever directly address physical memory.
3. Instead Kernel associates each process with unique address space.

Memory Management happens in Linux using Page and Paging.

Kernel allocates unique Virtual Address Space to each Process. This Virtual Address Space is composed of Pages.

Two type of Pages we have
1. Valid  Page : Its associated with Physical Page or Secondary storage like disk.
2. Invalid Page : Its unused, unallocated piece of  Address space.

A program cannot use a page in secondary storage. It can use the page if it is associate with a page in physical memory.

Program -> Tries to access a Page on Secondary Storage -> MMU  generate Page fault->  Kernel does Page-in the desired page from secondary storage to Physical memory.

Imagine a Process tries to access a page on secondary storage. 

Since the page is not present, page fault occurs.

The Kernel intervenes and does Page-in the desired page to Physical memory from Secondary storage.


Interrupts and Interrupt handlers

If you are an embedded engineer, you might be dealing with interrupts in your daily work. Though its simple concept, its thought complex.

To put them in layman words, interrupts allow hardware to communicate with processor which in turn informs the Operating System to perform certain task.

Harware -> Interrupt -> Interrupt controller -> Processor -> Operating System ->  Serve Interrupt. 

Interrupt is physically produced by the hardware and directed into input pins on an Interrupt controller.

Once the interrupt is directed towards Interrupt controller, it informs the Processor.

Processor then notifies the underlying Operating System to handle the interrupt appropriately.

Operating system serves each Interrupt with unique handler and distinguishes each interrupt with its unique id.

Just remember above sequence, and it will help you during technical discussions.

Saturday, April 11, 2015

How to configure vi/vim for coding C - Indentation and file detection

How do we make vi-Vim not to use tab and use 4 spaces instead ?
How to make it  automatically indent code after curly brace blocks like Emacs does?
How to save these settings so that we never have to input them again?

I've seen other questions very often from vi/vim users.
 
Its pretty simple, add below lines to your .vimrc file under your home directory.

 filetype plugin indent on  
 set tabstop=4  
 set shiftwidth=4  
 set expandtab  

More information under :  filetype

Wednesday, April 8, 2015

Missing side bar, Missing Menu bar , Missing icons and Missing "close resize and minimize icons" in Ubuntu 14.04 64bit LTS

This issue was a nightmare. I have tried various solutions to solve this issue but nothing worked. I tried reinstalling unity, resetting unity, reinstalling compiz packages etc and ended up without solving the issue.

Many solutions available in net are for 12.04 , 12.10 etc versions but not for Ubuntu 14.04 64 bit version.

Before trying this solution, make sure you have taken backup of your valuable data. I didn't loose any data but on safe side, its always good to take backup before trying which we are not sure about it.

To solve this issue just change your directory to your home directory.

Press Ctrl+Alt+F1 , enter your username and password.

 cd <home-directory>  
 sudo rm -rf .config  
 sudo rm -rf .compiz/compiz-1  

That's it, reboot the machine and now you should see icons back on the screen :)