Patel406210322-004

atharvashira upanishad

atharvashira upanishad

This upanishad is based on atharva veda. It has total 7 kanDikaas.

[1]

rudra is one, past, present, future, soul of souls, all directions, eternal, mortal, expressed, concealed, brahman, non-brahman, male, female, neuter, all meters in poetry, all types of fires, truth, cow, gauri(his wife in worldly form), light, darkness, all vedas, eldest, respected, best, indestructible, destructible, pilgrim places, salubrious, sacred, eternal flame, energy.
Everything is within him – rudra.

[2]

Talks about eight planets. Mentions brahmaa, vishhNu being rudra.

[3]

Omkaara is praNava which is omnipresent. That omnipresent is flowing everywhere. That flows everywhere is subtle element. That subtle element is glowing and electrifying. That electrifying is parabrahma. parabrahma is one and that one is rudra.

Thus self consciousness, God’s consciousness and non-manifested consciousness above all are the same.

[4]

Omkaara is said thus because while pronouncing it, one has to bring breaths upward.
It is called praNava as it is used to bow down to ruk, yajuhu, atharva, angirasa and braahmaNas.
It pervades whole universe without being manifested, so it is called sarvavyaapi (omnipresent).
It is ananta (eternal) because there is no beginning or end while pronouncing it.
It is taaraka (savior) as it saves from fear of fetus, birth, aging, disease and death.
It is shukla (bright) as it is gives light to others.
It is called sookshma (subtle) as it becomes subtle after pronouncing it and remains in all bodies (physical, subtle, causal etc).
It is vidyuta (lightening) because it brightens all bodies even in darkness of ignorance.
It is called parabrahma as it expands para (non-manifested), apara (manifested) and paraayaNa (entangled).
It is brahman as it feeds on all lives and is ageless.
It is one and only one in all lives so it is called eka (one).
It is called rudra as it can be easily known by rushis (sages) and not by ordinary people.
It is called eeshaana (God) as it controls all energies and all devas (demi-Gods).
It is called maheshvara (supreme God).

[5]

rudra was manifested first.

If one attributes all accumulated deeds to rudra using intellect, s/he becomes one with paramaatman (supreme God).

The fourth half vowel in Omkaara is non-manifested form of all devas (demi Gods) and flows everywhere. It has pure crystalline form. Meditating upon its fourth half vowel sign brings liberation. This worship removes karmic bondage.

[6]

The whole world began from rudra that was in form of agni (fire).

rudra controls this whole world with dvidhaa (two – shiva and shakti) and tridhaa (three – sat, raja and tama). shakti is energy. shiva is welfare. Thus, dvidhaa is duality of mind and energy. sat is truth and light. raja is small particles. tama is ignorance and darkness. Thus tridhaa is material world made up of light, particles and darkness.

One who worships rudra’s moordhaa (top of head) in form of praNava (Omkaara) can attain highest position of atharvaa.

kaala (time) is born from akshara (indestructible).

When rudra starts sleeping, everything is destroyed. When he breathes, tama (ignorance and darkness) is created. tama creates aapaha (basic active element). Then rudra churns aapaha with finger so it coagulates. Further churning it, creates feeNa (foam). Foam creates brahmaanDa (cosmic egg). brahmaa comes into existence in that egg. brahmaa creates air. That air creates Omkaara. Omkaara creates saavitree (rays or waves). saavitree creates gaayatree (matter) and gaayatree creates animals.

[7]

One who reads atharvashira upanishad once, becomes pure and can attain welfare. Reading twice, one becomes ruler of humans. Reading thrice, one enters Omkaara which is in form of satya (truth) which is the only truth.

Patel406210322-004

Custom syntax with vim Chirag Patel August 10, 2015

Custom syntax with vim Chirag Patel August 10, 2015

On Linux, install vim if you do not have.
On Windows, install gVim (I tried 7.4).

Create vjn.vim file similar to following example.

Vim syntax file
Language: config file
Maintainer: Chirag Patel

if exists(b:current_syntax)
finish
endif

:syn keyword error ERROR
:syn keyword warn WARNING

:syn keyword user chirag vrund svara parul
:syn keyword admin digant vikas hina

hi def error guibg=red guifg=white
hi def warn guibg=yellow guifg=black

hi def user guifg=tomato1
hi def admin guifg=deep pink

Check vim74/rgb.txt file to find color definitions.
Add vjn.vim to vim74/syntax folder.
Edit vim74/filetype.vim file and add following lines to alphabetical order of file types.

Config
au BufNewFile,BufRead *.vjn setf vjn

You are all set to have fun and have interesting configuration file looks.

Also, do not forget to add following to your vim settings (_vimrc or .vimrc) for more fun.

colorscheme slate
set guifont=Courier_New:h10:cANSI
set autoindent
set ts=4
set softtabstop=4
set shiftwidth=4
set incsearch
set hlsearch
set nowrap
set noexpandtab
set showmatch
filetype on
syntax on
set ruler
set cindent
set noswapfile
set mat=5

Patel406210322-004

Memory Thrashing compiled by Chirag Patel December 27, 2008

Memory Thrashing compiled by Chirag Patel December 27, 2008
(Ref: Embedded Systems Design June 2008)

Memory threshing is a typical problem that goes unnotices while programming time-critical systems. Translation Look-aside Buffers (TLB) are used for data and instruction cache. There are two main cache-replacement schemes: 1) Least Frequently Used (LFU) and 2) Least Recently Used (LRU). Memory accesses require address translations in modern systems. So, when a page table is is found in an on-chip TLB (a TLB hit), the lookup normally does not do translation. On TLB miss, the processor must look again and must calculate offset to find a byte physically.

When a system has multiple concurrent accesses, operating system schedules time slices for those processes. If we consider 32-entry LRU TLB and 6 processes each using different page memory, at least 12 pages are active at any given time (instruction + data). If every process uses double nested procedures (or jumps between 3 pages) in each time slice, there are 36 active pages. If operating system time slices sequentially, by the time 6th process is reached, 30 pages are accessed. By the end of 6th process time slice, 36 page accesses should have passed. So, the cache manager will discard first 4 accesses (LRU algorithm). When the time comes for the first process, it will have TLB misses for those first 4 page accesses. As the processor continues, it keeps discarding the pages that the next process in sequence will need. This memory thrashing greatly degrades system performance.

To avoid thrashing:
– Long unused variables should be declared absolutely rather than relatively.
– Macros should be expanded.
– Avoid nesting procedure calls whenever possible.
– Minimize number of concurrent tasks.
– Don’t use jumps larger than page size unless absolutely necessary.

Patel406210322-004

double precision comparison in c++ – chirag patel

Checking double precision value for limits is tricky.

Say,

double x = 1.0;
if ( x == 1.0 ) do_something();

 

This comparison can fail as double precision value when converted to hexadecimal (what computer can do only) representation, looses some least significant bits or positions beyond double precision digits. So, in above example if ( x == 0.9999999 ) might have worked depending on compiler and/or CPU. Therefore, in programming, we create functions to check such limits to approximate values.

 

// Used for double type comparasion
typedef union mydouble_ {
    double dbl_val;
    unsigned long un_u32_val[2];
    unsigned char un_u8_val[8];
} mydouble;

 

// Checks double value against close enough limits i.e. min <= val <= max
// Return: -1 => val < min
// Return: 0 => min <= val <= max
// Return: 1 => val > max
int my_double_limit_check( double val, double min, double max )
{
    mydouble dbl;
    mydouble cmp;
    int ret = 0;
 
    if ( val < min )
    {
        dbl.dbl_val = val;
        cmp.dbl_val = min;
        if ( dbl.un_u32_val[0] != cmp.un_u32_val[0] )
            ret = -1;
        else if ( dbl.un_u8_val[4] != cmp.un_u8_val[4] )
            ret = -1;
    }
 
    if ( val > max )
    {
        dbl.dbl_val = val;
        cmp.dbl_val = max;
        if ( dbl.un_u32_val[0] != cmp.un_u32_val[0] )
            ret = 1;
        else if ( dbl.un_u8_val[4] != cmp.un_u8_val[4] )
            ret = 1;
    }
 
    return ret;
}
 
// Checks double value against close enough less value i.e. val < min
// Return: -1 => val < min
// Return: 0 => val >= min
int my_double_less_check( double val, double min )
{
    mydouble dbl;
    mydouble cmp;
    int ret = 0;
 
    if ( val < min )
    {
        dbl.dbl_val = val;
        cmp.dbl_val = min;
        if ( dbl.un_u32_val[0] != cmp.un_u32_val[0] )
            ret = -1;
        else if ( dbl.un_u8_val[4] != cmp.un_u8_val[4] )
            ret = -1;
    }
 
    return ret;
}
 
// Checks double value against close enough greater value i.e. val > max
// Return: 1 => val > max
// Return: 0 => val <= max
int my_double_greater_check( double val, double max )
{
    myouble dbl;
    myouble cmp;
    int ret = 0;
 
    if ( val > max )
    {
        dbl.dbl_val = val;
        cmp.dbl_val = max;
        if ( dbl.un_u32_val[0] != cmp.un_u32_val[0] )
            ret = 1;
        else if ( dbl.un_u8_val[4] != cmp.un_u8_val[4] )
            ret = 1;
    }
 
    return ret;
}
 
// Checks double value against close enough equal value i.e. val == eql
// Return: 0 => val == eql
// Retrun: 1 => val != eql
int my_double_equal_check( double val, double eql )
{
    mydouble dbl;
    mydouble cmp;
    int ret = 0;
 
    if ( val != eql )
    {
        dbl.dbl_val = val;
        cmp.dbl_val = eql;
        if ( dbl.un_u32_val[0] != cmp.un_u32_val[0] )
            ret = 1;
        else if ( dbl.un_u8_val[4] != cmp.un_u8_val[4] )
            ret = 1;
    }
 
    return ret;
}

Patel406210322-004

double precision rounding – chirag patel

Uses my_double_greater_check from http://rutmandal.info/double-precision-comparison-in-cc/

double my_double_round( double val, int multiplier )
{
         double val_adj = val * multiplier;
         if ( my_double_greater_check( val_adj floor( val_adj ), 0.0 ) > 0 )
                      val = round( val_adj ) / multiplier;
         return val;
}

round and floor are C math library <math.h> functions.

E.g.

double rnd_val = my_double_round( 0.000998, 1000);

rnd_val will be 0.001