Tuesday, August 14, 2012


What the Jumper settings will do ?
 Jumper is used to make short circuites between two or more pins.
One of the real usage is Primary and secondary hard disk is configured via jumper settings.


How CPU usage is calculated ?
1.Assume if the CPU speed is 1KHz then it will executes 1000 cycles/second [/read 1000 bits per second]
   
  If we are doing program which requires 500 cycles/ second means then CPU usage is 50%. Rest of the 50 % can be used for other
process or program.
 
  if the program is more intensive and takes 1000 cycles/second to execute, then no more process can run that time. So CPU is so busy in executing the program.
For any external event/program it will respond slowly.

 Normally CPU speed is measured in GHz nowadays.

1KHz = 1000 Hz
1MHz = 1000 KHz
1GHz = 1000 MHz

Sunday, August 12, 2012

indian companies in jeans/shirts/pants

List of indian companies in jeans product:

Indian companies in jeans:

1.Flying machine
2.Shoppers stop
3.Mufti -available in shoppers stop,central,westside, globus
- available in Shoppers stop
- range from Rs 1000
4.New Port -Arvind mills india
5.Excalibur- Arvind mills india
6.integriti jeans
7.Spykar jeans
8.Numero uno
9.K-Lounge
10.lawman pg3
11.Bare denim -Pantaloon group
12.Killer jeans - kewal clothing ltd
13.Trigger jeans
14. DJ & C jeans [from Big Bazaar]

Indian companies in Shirts & Pants:
1.Blackberry's
2.Indian terrain[From chennai]
3.Raymond
4.Zodiac
5.Grasim
6.Qwalior
7.Color Plus [is from Raymond]
8.Pantaloon[their own brand clothes mostly]
9.Shoppers Stop [their own brand clothes mostly]
10.globus


if you know any indian company in shirts/jeans business, Please replay
& add it too.

Thursday, August 02, 2012


Why YUV format is used in MPEG2/MPEG4/H264encoders for compression ?

  MPEG2/MPEG4/H264 is lossy compression.
RGGB will have image details/color information in all the RGB represented bytes.
if we are applying for lossy compression, there is a chance for losing bits information.
if LSB bits are affected there wont be a big change in image. If MSB bits of RGB is lost,
this will be bigger change in image and user can perceive/can observe the changes in image.

  In YUV format, image details will be available in Y data[ this will have monochrome/ black and white image]. U and V component is used to store color information.

  Eyes can't perceive color information changes than image information. But it can easily observe the changes in image information[Y data which will have black/white image]. So In lossy compression, encoders wont disturb the image information & will
disturb or compress more in color information [UV components]

     If we are using RGB, we cannot separate image information & color information.Because all the pixels will have the image information and color information.

This is the reason why we are using YUV format in lossy compression or MPEG2/MPEG4/H264 encoders.


   

Friday, July 27, 2012

Dalvik Debug Monitoring System:



DDMS is integrated into Eclipse and is also shipped in the tools/ directory of the SDK. DDMS works with both the emulator and a connected device. If both are connected and running simultaneously, DDMS defaults to the emulator.
  • From Eclipse: Click Window > Open Perspective > Other... > DDMS.
  • From the command line: Type ddms (or ./ddms on Mac/Linux) from thetools/ directory

    How DDMS Interacts with a Debugger

    When DDMS starts, it connects to adb. When a device is connected, a VM monitoring service is created between adb and DDMS, which notifies DDMS when a VM on the device is started or terminated. Once a VM is running, DDMS retrieves the the VM's process ID (pid), via adb, and opens a connection to the VM's debugger, through the adb daemon (adbd) on the device. DDMS can now talk to the VM using a custom wire protocol

    DDMS features summary:/when we will use DDMS ?
    For the following purpose, we can use DDMS.
    1.Viewing heap usage for a process
    2.Tracking memory allocation of objects
    3.Working with emulator or device's file system 
        we can copy video files/files to emulator or device with DDMS
    4.using logcat : logs can be viewed and filtered based on LOG_TAGS
    5.monitoring network traffic information






Changes/Features in android  Icecream sandwich:

1.RTSP streaming was integrated with NuPlayer
2.Valgrind  static memory leak tool is ported to android
3.gdb is ported to android
4.OpenCV image processing library is ported to android that is why facedetection / recognition is possible in
ICS . Samsung S III ICS is having face detection functionality
5.OpenAL application layer support  [refer system/media/wilhelm folder path]
6.Subtitle support through TimedTextPlayer for video/audio playback
7.ION memmory manager support in ICS
[ ION is a generalized memory manager that Google introduced in the Android 4.0 ICS (Ice Cream Sandwich) release to address the issue of fragmented memory management interfaces across different Android devices. There are at least three, probably more, PMEM-like interfaces. On Android devices using NVIDIA Tegra, there is "NVMAP"; on Android devices using TI OMAP, there is "CMEM"; and on Android devices using Qualcomm MSM, there is "PMEM" . All three SoC vendors are in the process of switching to ION].
More about ION memory can be found : http://lwn.net/Articles/480055/
8.Framework for DRM
9.NuPlayer is introduced for HTTP live streaming in Honeycomb tablet. In ICS,  RTSP stack/streaming is removed from stagefright and integrated into NuPlayer
10. There are two ways to integrate the decoders in gingerbread
        i) Software decoder path [google decoders are integrated by deriving from MediaSource.InstantiateSoftwareDecoder() function is used within OMXCodec.
        ii) OMX path
       
  From ICS onwards, Google decoders are integrated in OMX Path and InstantiateSoftwareDecoder() is removed in stagefright




How will you identify the memory leaks in android ?
1.We can use valgrind tool to find memory leaks, stack corruption, array bound overflows etc
2 Valgrind tool is ported in Icecream sandwich onwards
3.From DDMS, we can select the process and start profiling, we have to do suspected memory leak operation,some file will be created.we can use eclipse memory analyzer tool to identify the memory leaks from this file
4.We can identify the memory leak by process. By putting ps command it will list down the memory occupied by process. Same can be viewed in settings option also. 


      If we want to check whether the video playback has memory leak or not,we have to type ps command to identify the memory occupied by mediaserver process. we can run the video continuously for 100 times or 200 times. Afterwards we have to check memory again for mediaserver process in ps command. if there is a great increase in memory, then we can confirm there is a memoryleak in a video playback. 


What is missing in Android Stagefright/NuPlayer RTSP streaming ?

1.Jitter buffer handling
2.RTCP handling
3.Error correction and feedback through RTCP Sender report/receiver report

What are all the buffering mechanism available in OMX ?
   1.AllocateBuffer - Allocates buffer
   2.UseBuffer - use the buffer given by the downstream component. Example using the video renderer's memory to fill the decoded data

When the input buffer or output buffer of the component should be released?
        Once the OMX input buffer is used and ready to release,  it will return the EMPTY_BUFFER_DONE event to the stagefright or who is owning the buffer. Once the IL client received the EMPTY_BUFFER_DONE event, it can release the input buffer.
     OMX  IL client will receives the FILL_BUFFER_DONE event from OMX component once the output buffer is used and ready to release. Once IL client received the FILL_BUFFER_DONE event, IL client will frees the output buffer.

How Seek operation is executed in Stagefright ?
        Once the application is giving seek, Thru stagefright player, awesome player calls the seek() function.

How seek operation is notified to the parser or Extractor ?
     within Awesomeplayer, SeekTo() fn is called, it will sets the ReadOptions structure values as seek mode set and seek timestamp is also stored in this structure.

     Awesomeplayer while calling decoder, it will  invoke decoder as below

            mVideoSource->read(&decodedBuffer, &readOptions);

This readoptions value is passed to decoder and decoder will have the pointer to the MPEG4/MKV extractor's media source.
       Decoder will invoke read() fn of the audio/video source of the extractor by passing readOptions.

within parser's media source ->read() fn, it will checks whether the seek mode is set or not. if it is set, it will
do seek to seektimestamp through parser.


                 

         

 

     

Wednesday, July 25, 2012

what is OMX Content Pipe  ?

From OMX IL 1.1 standard, we can integrate source[3GP parsers] or Streaming source /sink [MP4 muxer].

Through content pipe, it is possible for us to integrate the source/sink components.

Content Pipe specification explains on how it open/read/write positions from storage/ from network.

Friday, May 18, 2012

STL & GNU C++ with codeblocks

If we are using STL program in codeblocks, we have to enable GNU c++ option
by selecting

Project->Build options->Have g++ follow the coming C++ 0x ISO C++
language standard [-std =c++0x]

Otherwise it wont compile in codeblocks editor. while submitting the
same code in codeforces.com, we have to select
GNU C++0x4 option for uploading the cpp file.

BHTML & BCSS codeforces problem log

BHTML & BCSS codeforces problem log:

What are all the steps I have done to solve this problem:


For a problem, I started by generating the strings and tried to
compare the strings as follows:

<a><b><b></b></b></a>

Generated string [from HTML] is as follows:
a
a b
a b b

pattern a b has occurence as 2 times.

Pattern should be there in the generated string.

we need to check all the patterns and count/increment the current occurence.

This approach is taking more time, I got "timeout exceeded".

Once again I got failed in substring test case.

for example, <sundar/>
for pattern :sun it should return 0. But it is returning some other values
I stored the values in hashtable and added the number in an array.
instead of comparing strings, I started comparing
integer values.



1)timeout exceeded
2)substring testcase failure <sundar/> query:sun but output is 1. it should be 0
3)string comparison takes time, I added the string in hashtable and
generated the int array to compare & reduce
time
4) Integer comparison also takes around 7 seconds for a problem &
failed in somecases giving improper output.
5) I checked the case of seulgi kim's code. Based on my understanding,
I have created
Nary trees from the HTML. From Nary trees, we will search for the
given query recursively.

6.Through debugging found that PushToStack should be available for
<tag/> cases too
7.Modified the PreOrder() fn return as Long
8.modified the readQuery() to read char by char
9.deleted the query array and created it for each query
10.Tried by changing the stack size limit.
#pragma comment(linker, "/STACK: 2000000")

11. I doubted the readQuery() but I am getting large size input for the query.
I changed the Maximum Query characters Count[MaxQueryCount] from 250
to 4000. Now I have posted it, it was working fine & accepted in the
codeforces.
I thought like query line will have maximum 250 characters. I haven't
read properly about the problem sentences:

" Each query is a sequence x1, x2, ..., xn, where xi is the i-th
element of the query, and n (1 ≤ n ≤ 200) is the number of elements in
the query. The elements are separated by single spaces. Each query
doesn't begin with and doesn't end with a space. Each query element is
a sequence of lowercase Latin letters with length from 1 to 10."

200[queries] * 10 [tag size]* 199 spaces = 398000 characters it can
be...But since the testcases are having less than this limit, I am
able to run with 4000

12.Eventhough I successfully submitted the code in codeforces, I could
found one more problem... that is allocated nodes are not released
properly. I released all the nodes including parent nodes & resubmitted it...

Monday, May 14, 2012

Competition Sites to practice

1 UVA:http://acm.uva.es/p - The Valladolid University Online Judge.
Over N problems, for a reasonable value of N. The problems are culled
from old contests, and online contests.
2.ZJU:Zhejiang University Online Judge - http://acm.zju.edu.cn
3.SGU:Saratov State University Online Contester - http://acm.sgu.ru
4.PKU: Peking University Judge Online of ACM ICPC -
http://acm.pku.edu.cn/JudgeOnline
5.topcoder
6.codeforces

Wednesday, May 09, 2012

Books recommended in codechef

1. Standard book on Algorithms - Introduction to Algorithms by T H
Cormen, C E Leiserson, R L Rivest, C stein ( Famously known as CLRS )
2. Basic Algorithms - Algorithms by Richard Johnsonbaugh, Marcus Schaefer
3. Game Theory - Winning ways for your mathematical plays by Elwyn R.
Berlekamp, John H. Conway, Richard K. Guy
4. Programming challenges - Steven Skienna
5. Concrete Mathematics - Knuth
6. How to solve it by a computer - Dromey
7. Structure and interpretation of computer programs - Elsevier
8. Programming Language Pragmatics - Micheal Scott : It gives
comparative study of various programming languages and helps you
decide choose the appropriate ones on the basis of time they take to
process information

How P frame seek support will be added in any multimedia framework

Some multimedia frameworks will have support for P frame seek. Some
frameworks wont have this support. So How can we add this support ?

For P frame seek, we can not start directly start decoding & rendering
from the P frame;
Since P frame doesnt have entire frame information, if we start
decoding & rendering from P frame, it will shows
green patches on screen and affect the user experience.


How P frame seek is supported in Directshow multimedia framework ?


For any seek timestamp, Parser will seek the I frame timestamp before
the seek timestamp.
Ex :
I frame is available in 10th second.
if the seek is done to 12th second, the Parser will fetch I frame from
10th second and give it do the decoder.

Source Filter will set IMediaSample's SetPreroll() as true. The
decoder will decode the frame,get necessary information and wont give
it to the renderer.

Once the timestamp reached the seek timestamp, Parser will set the
setPreroll as false, then frame will starts rendering.


OpenCORE:

In OpenCORE's frame have an option to set DoNotRender flag. If we set
this flag, it wont render the given frame.

In Generic, In any multimedia framework,

if we are calling seek to any timestamp, Upto seektimestamp is
reached, video and audio frames are dropped without rendering on
hardware device.In case of audio, we will have more I frames. But if
we are rendering audio alone, video takes more time to catchup
video.User might be able to observe the weird behaviour since ear is
more sensitive than eyes. In this scenario, rendering the audio also
causes the audio clock to increase. It will cause AV sync issues once
video starts rendering.

In any multimedia framework, we have to do the following steps to
do P frame seek:



1.ParserseekTo(Nearest_I_Frame to SeekTimesamp);
2.ParserRead(frame);
3.Decode(decodedAudioVideoFrame);

4. if (decodedAudioVideoFrameTimestamp < SeekTimestamp)
{
release audioVideoFrame;
}
else
render(decodedAudioVideoFrame);

weird video behaviour in Stagefright

In stagefright, if any weird behaviour is observed in video. Following
steps need to be taken:

1.we need to print time taken by parser and decoder.[To check any time
taken process involved]
2.Check any frame is dropped by enabling log [dropping late frame in
awesomeplayer.cpp]
3.Print logs in all sleep() fn in AwesomePlayer[while rendering
frames, threads might go to background and wont do anything because of
Sleep() fn
4.Check for any postVideoEvent(10000ms) this might delay the rendering
of frames. For optimization or any other reason, chipset vendors might
tune this
value

String comparison

Whenever we need to compare strings, what we can use it?

Text: abc bcd bcd abc
Pattern: abc bcd
[Ex: BHTML & BCSS codeforces problem]

we need to compare text and pattern using strcmp. But naive string
comparison takes more time.

Solution 1)we can use RobinKarp or KMP algorithm to reduce time. or
else we can do the following way to avoid the problem.


How to avoid this:

we can use array to store the strings without duplication.

Array [][]={ "abc","bcd"}

Text Array: {0,1,1,0}
Pattern Array: {0,1}

then apply naive comparison in TextArray and pattern Array.

Solution 2)Compare to string array, int array comparison will takes less time.

Solution 3) if we are using array also, we need to compare all the
elements in array on worst case to add or lookup.
in this case, what we can do to improve this ?

We can use Binary Search Tree to store strings. if the given
string is less than the root string,
we need to search it from left child of the string.if it is greater
than or equal to the rootstring, we need to search the
right child of the root.

STL map is using RedBlack tree implementation. we can make
use of map to store strings.STL map can also be used for Hashtable.

Thursday, May 03, 2012

DecodeButDoNotRender

Insights on How to implement DecodeButDoNotRender flag in any
multimedia framework ?
This will happen when we dont have more I frames.

Wednesday, April 25, 2012

what is structure padding ?

what is structure padding ?

if the system is 32 bit system,
we are allocating memory like this:

struct test
{
char a;
int b;
};

It will allocate 8 bytes of memory in 32 bit system. For char,compiler
will allocate the 4 bytes. [char may be 1 or 2 bytes]
this is called data alignment. Data alignment means putting the data
at a memory offset equal to some multiple of the word size,
which increases the system's performance due to the way the CPU handles memory.
For char, 4 bytes are allocated. it will use only 1 bytes.Rest of the
bytes are filled with junk values. this is called structure padding.

For example, in 32 bit system,the data to be read should be at a
memory offset which is some multiple of 4.
if the data starts from the 18th byte, computer has to read two 4
bytes chunks to read the data.
if the data starts from multiple of 4[4,8,12,16,20], computer can read
4 byte chunk once to read the data.
If the read is from two virtual memory pages, then it will take more
time than expected.

In this way, padding improves performance.


if the data members are declared in descending order it will give
minimal wastage of bytes.

struct Test
{
char a;
int b;
char c;
};

sizeof(Test) is 12 bytes.

But if we declared like this, 8 bytes will be allocated for structure "Test".


struct Test
{

int b;
char c;
char a;
};

How to avoid structure paddding?
if we dont want to waste memory & tradeoff the performance,
we need to use pragma pack to align data.

Tuesday, April 24, 2012

How OMX core library is loaded for stagefright by chipset vendor like Qualcomm /Nvidia ?

How OMX core library is loaded for stagefright by chipset vendor like
Qualcomm /Nvidia ?

Qualcomm and NVIDIA processors will have built-in hardware codecs support.
They will provide the OMX components too. Their OMX core will be
loaded from libstagefrighthw.so .
This libstagefrighthw.so library will be loaded by stagefright in
OMXMaster.cpp in

addPlugin("libstagefrighthw.so");

vertical/horizontal sync in video

Video Is Composed of a Series of Still Images.
changing fast enough that it looks like continuous motion.
timing informations are called vertical sync/horizontal sync.

vertical sync - indicates when a new image is starting
horizontal sync -indicates when a new scanline is starting

Each still is composed of series of scanlines.

Interlaced vs Progressive:
For displays that "paint" an image on the screen, such as a CRT,
Interlaced-each image is displayed starting at the top left corner of
the display, moving to the right edge of the display.

Interlacing: First odd number of pixels are sent to display and then
even number of pixels are sent to display the image.
Advantage: we can reduce memory transfered to display by half for every image.

Progressive: pixels are displayed by sequence of lines.For Higher
resolution, we go for progressive.
Interlaced: First half of image is displayed on screen and then next
half of image is displayed

string searching algorithms with code

http://www-igm.univ-mlv.fr/~lecroq/string/string.pdf

Friday, April 20, 2012

code forces FileList problem

Code forces FileList problem :

PseudoCode:
==============

#define MAX_FILENAME 8
#define TwoContinuousDots 0
#define SingleCharBetweenTwoDots 1
#define MAX_FILE_EXT 11
#define EndsWithDot 0
#define MAX_EXT 3


1.read the string input
2.Identify the dot & break the loop
3.if (stringBeginsWith == Dot) return NO;
4.if (CurrentCharPosition > MAX_FILENAME) //DotPosition exceeds
MAX_FILENAME allowed || Dot is not available within 8 character
return NO;
5.Store the ++LastDotPos
6.start loop through the string till EOS reached
7.if [ currentDotPos - lastDotPos == TwoContinuousDots ] { return NO;}
8.if ( CurrentDotPos - lastDotPos == SingleCharBetweenTwoDots ) { return NO;}
9.if ( CurrentDotPos - lastDotPos > MAX_FILE_EXT ) return NO;

At Last of the string,
10.if( CurrentDotPos - lastDotPos == EndsWithDot ) return NO;
11.if( CurrentDotPos - lastDotPos > MAX_EXT ) return NO; //Last
extension exceeds MAXIMUM_EXTENSION size
12.Yes... we are going to parse the valid String
13.create loop1... Search First Dot
14.if (char == FirstDOT) create loop2 and look for SecondDOT
15.if no second DOT and EOS reached,print string. [Ex: t.txt]
16.if(TwoDotsDiff <= MAX_EXT) printf( secondDot + 1 char);Move i by 1
17.else print (3 characters) Move i by 3

Thursday, April 19, 2012

Solve contest problems

To Solve any codeforces contest problems:

1)Prepare the testcases from the given problem statement
2)Prepare test samples
3)Prepare design
4)Check if any datastructure can be used & what will be the cons & pros
5)If multiple datastructure can be used, Identify the best
suitable datastructure
6) Sometimes tradeoff clarity/simplicity over efficiency
7) Once completed the code, test with test samples
8) if anyone has already submitted the problem, we can see the
testcases used for testing the solution.
we can check our code with codeforces simple testinputs
This will clarify if we misunderstood the problem statement.
[Ex: For Cd and PWd commands problem, from the problem
statement, I assumed that .. or / wont come at end.
But from the testsamples,I came to know this as a valid input]
9) Think on how to improve the code

After seeing others code,

1) Prepare testcases from code
2) Prepare testsamples to break the code
3) Randomly remove some lines of code and try to fix it...
This will give a chance to understand/read others code.

4.Identify any language functions/features used in code for
addressing particular scenarion & think of it
how to use it
5.Check the efficient code[less execution time] written by others
6.Check others code which is having clarity and simplicity

Tuesday, April 17, 2012

How to traerse/print character by character in a string without using strlen() ?

How to traerse/print character by character in a string without using strlen() ?


Usually we will do like this:

char szString[100]={0};
scanf("%s",szString);

for(int i = 0; i <strlen(szString); i++);
{
printf("%c",szString[i];
}


without knowing strlen(), we can print the same thing as below:

char szString[100]={0};
scanf("%s",szString);

for(int i = 0; szString[i]; i++);
{
printf("%c",szString[i];
}

if szString reaches NULL, it will returns zero, so for loop will be
terminated for that case.

Monday, April 16, 2012

find trailing zeros & its importance

How to find trailing zeros in factorial ?

Input : 6 = 2 * 3 * 4 * 5 = 120 = Trailing zeros = 1
Output : 1

For more detailed tutorial :
http://www.purplemath.com/modules/factzero.htm


#include <stdio.h>

void main()
{
long n =0;
long div = 5;
long sum = 0;

printf("Enter N! value:");
scanf("%ld",&n);

while(n >= div)
{
sum += n/div;
div *= 5;
}
printf(" Output is :%ld", sum);
}

Importance of finding the trailing zeros will be useful in floating
point representation.

It will be used to represent floating numbers
as 2 * (10 ^ 3)
mantissa: 2
exponent: 3

Same will be used to represent negative numbers in floating point
representation;

2 * (10 ^ -3)

Wednesday, April 11, 2012

Self synchronization Explicit AV synchronization in Stagefright

Self Synchronization or Explicit AV synchronization:
This is used in any file format. while creating AVI/MPEG4 file,
audio and video encoder data wont be written as such.
Encoded Video and audio frames are written to the file based on interleaving.
AudioFrame: A0 A1 A2
VideoFrame: V0 V1 V2
After interleaving, the data will be as like this: V0 A0 V1 A1 V2 A2
Interleaved data is written into file.
Interleaving can be based on number of frames or duration. Let us say
inteleaved duration is for 1 seconds.
Android stagefright is supporting this interleaved duration. Until
interleave duration is reached, MPEG4Writer will buffers data
in list. Once the interleaved duration is reached, it will be
signalled to MPEG4WriterThread.
MPEG4 Writer thread will write the queued samples in to the file.

Tuesday, April 10, 2012

DirectX Transform Editing Services

http://sworks.com/keng/da/multimedia/dtrans/c++/ - we can have the code for the DirectX Transform samples
http://com.it-berater.org/COM/webbrowser/filters_reference.htm

course on search engine/ text mining

http://net.pku.edu.cn/~course/cs502/2003/

Wednesday, March 14, 2012

AV Sync, Mixing two audio tracks in android

1. AV sync is undetectable if sound is rendered -100ms to +25 ms to video
- Sound Delayed
+ Sound advanced


2.How android audio flinger is mixing two or more tracks in mixer thread ?

 [How to mix two or more audio streams/tracks together ?]

If you want to mix streams A & B, you simply sum the corresponding samples: A1+B1=C1, A2+C2=B2... An+Bn=Cn...
Of course, both streams must have the same sample rate (and with integer formats, both must have the same bit-depth) before you sum.

    With integer formats you have to scale the input streams before summing (i.e. divide by 2), or you need to allow for
larger numbers (more bits) in the output stream. Even with 32-bit floating point, you'll normally want to scale before or after mixing to avoid clipping.
(The 32-bit data won't clip, but you can clip the DAC output.)

And frequently with audio mixing, you'll want to scale the input levels because you don't always want a 1:1 mix... You may want one signal to be louder in the mix.  Audio flinger is mixing one or more tracks as mentioned above.

 

From:http://www.hydrogenaudio.org/forums/index.php?showtopic=79430

 

Sunday, March 11, 2012

How localplayback errors are notified from C++ to java mediaplayer/ mediarecorder layer/Application in android ?

How localplayback errors are notified from C++ to java mediaplayer/ mediarecorder layer/Application in android ?


Java layer will have

MediaPlayer
{
  public static void postEventFromNative() { Notifies Error or Information events to Application thru InfoListener or ErrorListener }

};

JNI:
=====

JNIMediaPlayerListener/ JNIMediaRecorderListener is passed to underlying c++ mediaplayer or mediarecorder [libmedia] object.

whenver C++ mediaplayer or media recorder encounters errors it will call JNIMediaPlayerListener's notify () fn.

JNIMediaPlayerListener's notify/JNIMediaRecorderListener's notify is implemented in JNI.


void JNIMediaPlayerListener/JNIMediaRecorderListener::notify(int msg, int ext1, int ext2, const Parcel *obj)

{
   
    fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative",
                                               "(Ljava/lang/Object;IIILjava/lang/Object;)V");
  env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
                msg, ext1, ext2, NULL); //This will call the postEventFromNative() fn in Java...
 
}

Tuesday, February 28, 2012

How to detect if one of the linked list pointer is corrupted or not ?

How to detect if one of the linked list pointer is corrupted or not ?

0.In case of doubly linked list, by checking the prev/next pointer, we can identify whether the pointer is valid or not...
1.We can add some extra field to store the count of the linked list node  from 1,2,... and so on. For any node we can check the value with previous node value
2.we can make use of virtualquery() fn in windows to check whether the given address is valid or not.
In the same way, in linux, we will be having mprotect() fn. if we are passing the invalid address in mprotect(), it will notifies the application
with SIGSEGV signal, Application need to catch this signal and do the necessary things.
 

Monday, February 27, 2012

blessing

There is no disaster that cannot become a blessing and no blessing that cannot become a disaster - Richard Bach

Soviet Era math. books link

http://mirtitles.org/

Thursday, January 26, 2012

Lock based synchronization and Lock free synchronization

Lock based synchronization provides the following problems
1.Deadlock

2.LiveLock

3.Priority Inversions

4.Caravan Formation

To avoid these problems, we are going for lock free synchronization. AsynchronousProgramming is a typical technique for achieving lock free synchronization.

Example: Android Stagefright is having lock based synchronization mechanism

PV's OpenCORE is having lock free synchronization mechanism

Tuesday, January 03, 2012

How to add logs into android.mk [to display the information at compile time]

How to add logs into android.mk file:
 
This log will be printed whenever we are compiling.
Usecases: In a large project, somewhere the values will be set, User wont be aware of it.
So that time,to print which device macro is enabled, we can make use of this warning in android.mk

within Android.mk,

ENABLE_CODEC =1
ifeq(ENABLE_CODEC,true)
$(warning SUNDARA::ENABLE_CODEC is true)
else
$(warning SUNDARA::ENABLE_CODEC is false)
endif

#How to print the variable from Android.mk

TARGET_PLATFORM := MSM7227
$(warning SUNDARA::Target Plarform is '$(TARGET_PLATFORM)')

output:
SUNDARA::ENABLE_CODEC is true
Target Plarform is MSM7227

Monday, December 19, 2011

Think clearly

 The scientists of today think deeply instead of clearly. One must be sane to think clearly, but one can think deeply and be quite insane.

Friday, November 25, 2011

Tao Te Ching.

Tao Te Ching. Although it's a philosophy book and not a programming book, some of it's principles are very applicable to programming:

"Know when it's time to stop. If you don't know then stop when you are done."

Translation: Knowing your requirements means you know when to stop. If you don't know when to stop, you need to stop because the requirements have yet to be defined.

"The harder one tries, the more resistance one creates for oneself."

Translation: How many times have you worked on a problem for several hours, only to find the answer after taking a 15-minute break? The more you hammer at a problem, the harder it is going to be for you to solve it.

"One whose needs are simple can fulfill them easily."

Translation: Simple requirements lead to simple designs.

"When we lose the fundamentals, we supplant them with increasingly inferior values which we pretend are the true values."

Translation: Hubris is never a good substitute for good programming standards. If you get lax, no amount of design patterns will ever substitute for the lack of quality in your code.

Gmail Tricks

Tricks of Gmail:
===================
1.if your gmail id is something like this.

   a.sundara@gmail.com

Then you can login gmail as asundara or a.s.u.n.d.a.r.a@gmail.com [Any number of dots in between your mail user ID]

if anyone is sending mail to asundara@gmail.com, then you will receive mail in your inbox.

Monday, November 14, 2011

Putty Inactive problem

Problem:

1.Usually I will put some compilation in server through putty and leave for the lunch. after some timeout period, putty will goes to inactive mode.
But the server is compiling our code
2.After sometimes, I come back. There is a chance like due to slowness of the server,it might takes some more time to complete the compilation.
    
        How can we ensure the completion of compilation in this scenario ?

Solution:
  we can give compilation command | tee log.txt and redirects the compilation output to file log.txt. Once the compilation is done, the compilation message /errors will be stored in log.txt. From this log.txt, we can figure out whether compilation is completed or not.

Thursday, November 10, 2011

Tuesday, November 08, 2011

Wednesday, November 02, 2011

Harvesting techniques to use right side of the brain:

Harvesting techniques to use right side of the brain:

1.Free Form Journaling – Writing is a great way to relax your mind and allow your R-mode thoughts and ideas to escape your brain and present themselves onto paper. When ideas pop into your head, write them down, and then elaborate on those ideas. Simple brainstorming on paper can give you the opportunity to clarify your thoughts.

2.Walking – Sometimes the best way to come up with ideas is to simply step away from your desk, relax your mind, and go for a walk. While you're walking though, try not to think about anything, especially the problem you are trying to solve. The goal is to silence your L-mode and give your R-mode the chance to do some work.

3.Image Streaming – This is the process of deliberately observing images in your mind and paying close attention to them. First, pose a problem to yourself or ask yourself a question. Then shut your eyes and relax. As images start to cross your mind describe them out loud. Try to describe as many details as you can using all five senses. This type of thinking can help you discover fresh insights to the problem or question you presented yourself.


 

PQ RAR for effective reading


Try the PQ RAR reading-study method as you read or teach your next textbook chapter.

P-First of all, preview the reading selection. Try to limit the reading selection to a manageable size. Overly long chapters, say over six pages for

elementary students, eight for middle school students, twelve for high school students, and sixteen for college students should be "chunked" into manageable

reading sections.

1. Preview the first and last paragraphs of the chapter and the chapter review, if one is provided.

2. Preview all subtitles and any book study helps at the beginning of the chapter.

3. Preview all graphics such as photographs, charts, maps, etc. and their captions.

Q-Secondly, make use of text-based questions to read textbooks effectively.  Good questions produce good answers and significantly increase expository

comprehension. Determining questions before reading provides a purpose for reading, that is-to find the answers as you read.

1. Develop questions from the subtitles and write these down on binder paper or on your computer, skipping lines between each question. Try "What," "How,"

and "Why" question-starters. Avoid the "Who" and "When" questions, as these tend to focus attention on the minor details of expository text.

2. Write down any chapter review questions not covered by your subtitle questions, skipping lines between each question.

R-Read the chapter and "talk to the text" by taking notes in the textbook margins. Use yellow stickies and paste them in the textbook margins, if you can't

write in the textbook. Write down comments, questions, predictions, and connections to other parts of the reading and your own life experiences. List

examples, key details, and important terms with their definitions. Internal monitoring of the author's train of thought and the connection to your own

knowledge and experience increases comprehension as you read textbooks.

A-Answer both the subtitle questions and the book questions as you read. Write down your answers underneath your questions. Don't be concerned if the

textbook did not answer some of your reader-generated questions.

R-Review the questions and answers within the next 24 hours to minimize the effects of the "forgetting cycle." Generate possible test questions and
develop  memory tricks for key concepts and details.
 

SQ3R process

SQ3R is a simple strategy that can be used to actively engage yourself in whatever it is you are reading. The SQ3R process is as follows:

Survey – Scan the chapter headings and summaries for an overview.
Question – Note any questions you have.
Read – Read in its entirety.
Recite – Summarize, take notes, and put in your own words.
Review – Reread, expand notes, and discuss with colleagues.

Tuesday, November 01, 2011

From Pragmatic programmers

A tourist visiting England's Eton College asked the gardener how he got the lawns so perfect. "That's easy,"
he replied, "You just brush off the dew every morning, mow them every other day, and roll them once a
week."
"Is that all?" asked the tourist.
"Absolutely," replied the gardener. "Do that for 500 years and you'll have a nice lawn, too."
Great lawns need small amounts of daily care, and so do great programmers.

"Kaizen" is a Japanese term that captures the concept of continuously making
many small improvements. It was considered to be one of the main reasons for the dramatic gains in productivity and
quality in Japanese manufacturing and was widely copied throughout the world. Kaizen applies to individuals, too.
Every day, work to refine the skills you have and to add new tools to your repertoire. Unlike the Eton lawns, you'll
start seeing results in a matter of days. Over the years, you'll be amazed at how your experience has blossomed and
your skills have grown.

Friday, October 21, 2011

infancy

If life were measured by accomplishments, most of us would die in infancy- A.P.Gouthey

Sunday, October 16, 2011

Knowledge

Practice Drill #1:   Write your resume. List all your relevant skills, then note the ones that will still be needed in 100 years. Give yourself a 1-10 rating in each skill.
 
This drill will help you see where you need practice. It won't turn up your "blind spots" -- i.e., areas that you don't know anything about (hence aren't on your resume) but that you should know something about. But it'll at least help you see how current your working skillset is, and how long you expect it to stay current.
 
math, computer science, writing, and people skills are for the most part timeless, universal skills even after 100 years also, it will be useful. Most specific technologies, languages and protocols eventually expire, to be replaced by better alternatives.

10 great books

http://sites.google.com/site/steveyegge2/ten-great-books

reg. amazon

http://sites.google.com/site/steveyegge2/five-essential-phone-screen-questions

Thursday, October 13, 2011

MutexLock hangs in StageFright:


MutexLock hangs in StageFright:

   1.This might happens due to invalid use of[if we have added any] the mutex lock / invalid call sequence.

We observed mutex lock hang for the below scenario:

    mPlayer.SeekTo(10);
    mPlayer.Start();


We should call like this:

  mPlayer.SeekTo(10);
  mPlayer.OnSeekCompletionListener()
  {
    mPlayer.Start();
    
  }

or


  mPlayer.SeekTo(10);
  WaitForEvent();
  mPlayer.Start();

   OnSeekCompletionListener()
  {
    TriggerEvent();
  }

 

time

“Being with you and not being with you is the only way I have to measure time.”
Jorge Luis Borges

Tuesday, October 11, 2011

To learn an algorithm

To learn an algorithm well, one must implement it. Accordingly, the
best strategy for understanding the algorithm is to
implement and test them, experiment with variants, and try them out on
real problems.

Monday, October 10, 2011

Ruler multiplication

File:Slide rule example2.svg

2 * 3 = 6 we can match slide ruler 1 and ruler 2.

Sunday, October 09, 2011

why stability is important in sorting algorithms?



Ans1: For parallelization purposes? eg: merge sort is stable and can be parallelized well and so is quicksort.


Ans2:

Background: a "stable" sorting algorithm keeps the items with the same sorting key in order. Suppose we have a list of 5-letter words:

peach straw apple spork

Stable-sorting by the first letter gives us:

apple peach straw spork

In an unstable algorithm, straw or spork may be interchanged, but in stable sort, they stay in the same relative positions (that is, since 'straw' appears

before 'spork' in the input, it also appears before 'spork' in the output).

Ans 3:
There's a few reasons why stability can be important. One is that, if two records don't need to be swapped by swapping them you can cause a memory update, a

page is marked dirty, and needs to be re-written to disk (or another slow medium).

Ans 4:
  Stable sort will allways return same solution (permutation)

Ans 5:

Sorting stability means that records with the same key retain their relative order before and after the sort.

So stability matters if, and only if, the problem you're solving requires retention of that relative order.

If you don't need stability, you can use a fast, memory-sipping algorithm from a library, like heapsort or quicksort, and forget about it.

If you need stability, it's more complicated. Stable algorithms have higher big-O CPU and/or memory usage than unstable algorithms. So when you have a large

data set, you have to pick between beating up the CPU or the memory. If you're constrained on both CPU and memory, you have a problem. A good compromise

stable algorithm is a binary tree sort;


memory usage on Merge Sort is O(N), while on Quicksort it's O(log N).

Monday, October 03, 2011

Petr quotes 2

"Do not spend all your time on training or studying - this way you will probably become very exhausted and unwilling to compete more. Whatever you do - have fun. Once you find programming is no fun anymore - drop it. Play soccer, find a girlfriend, study something not related to programming, just live a life - programming contests are only programming contests, and nothing more. Don't let them become your life - for your life is much more interesting and colorful."

Petr quotes

"I think that two main keys to programming contests are training and thinking. You have to solve a lot of problems to become really successful, but you also need to have good math knowledge and the ability to solve uprising problems. Mathematical puzzles and olympiad problems, for example, can help develop it very well. And you have to be confident. Confident that you'll be successful. That you'll win eventually. And the feeling of being a winner, it will reward you for all the difficulties."

Thursday, August 18, 2011

Pablo Neruda

We the mortals touch the metals,
the wind, the ocean shores, the stones,
knowing they will go on, inert or burning,
and I was discovering, naming all the these things:
it was my destiny to love and say goodbye."

— Pablo Neruda (Still Another Day)

Tuesday, August 16, 2011

desire

Some desire is necessary to keep life in motion

Saturday, August 06, 2011

truth

when you have eliminated the impossible, whatever remains, however improbable, must be the truth- sherlock holmes

Thursday, August 04, 2011

Mirror

Mirror is my best friend because when I cry it never laughs at me

Wednesday, August 03, 2011

You must keep your mind on the objective, not on the obstacle

You must keep your mind on the objective, not on the obstacle

Monday, August 01, 2011

Be the change

Be the change you want to see in the world -Gandhi

Thursday, July 21, 2011

All a man needs in this life

All a man needs in this life is someone to love. If you can't give him that, give him something to hope for. If you can't give him that... give him something to do.

warning

Warning: If you are reading this then this warning is for you. Every word you read of this useless fine print is another second off your life. Don't you have other things to do? Is your life so empty that you honestly can't think of a better way to spend these moments? Or are you so impressed with authority that you give respect and credence to all that claim it? Do you read everything you're supposed to read? Do you think every thing you're supposed to think? Buy what you're told to want? Get out of your apartment. Meet a member of the opposite sex. Stop the excessive shopping and masturbation. Quit your job. Start a fight. Prove you're alive. If you don't claim your humanity you will become a statistic. You have been warned- Tyler.

Every evening I died, and every evening I was born again, resurrected.

Every evening I died, and every evening I was born again, resurrected.

free to do anything

It's only after we've lost everything that we're free to do anything.

Tuesday, July 12, 2011

First day

Today is the first day of the rest of your life"? Well, that's true of every day but one - the day you die

Friday, July 01, 2011

How to Solve it by G.Polya

  1. UNDERSTANDING THE PROBLEM
    • First. You have to understand the problem.
    • What is the unknown? What are the data? What is the condition?
    • Is it possible to satisfy the condition? Is the condition sufficient to determine the unknown? Or is it insufficient? Or redundant? Or contradictory?
    • Draw a figure. Introduce suitable notation.
    • Separate the various parts of the condition. Can you write them down?
  2. DEVISING A PLAN
    • Second. Find the connection between the data and the unknown. You may be obliged to consider auxiliary problems if an immediate connection cannot be found. You should obtain eventually a plan of the solution.
    • Have you seen it before? Or have you seen the same problem in a slightly different form?
    • Do you know a related problem? Do you know a theorem that could be useful?
    • Look at the unknown! And try to think of a familiar problem having the same or a similar unknown.
    • Here is a problem related to yours and solved before. Could you use it? Could you use its result? Could you use its method? Should you introduce some auxiliary element in order to make its use possible?
    • Could you restate the problem? Could you restate it still differently? Go back to definitions.
    • If you cannot solve the proposed problem try to solve first some related problem. Could you imagine a more accessible related problem? A more general problem? A more special problem? An analogous problem? Could you solve a part of the problem? Keep only a part of the condition, drop the other part; how far is the unknown then determined, how can it vary? Could you derive something useful from the data? Could you think of other data appropriate to determine the unknown? Could you change the unknown or data, or both if necessary, so that the new unknown and the new data are nearer to each other?
    • Did you use all the data? Did you use the whole condition? Have you taken into account all essential notions involved in the problem?
  3. CARRYING OUT THE PLAN
    • Third. Carry out your plan.
    • Carrying out your plan of the solution, check each step. Can you see clearly that the step is correct? Can you prove that it is correct?
  4. Looking Back
    • Fourth. Examine the solution obtained.
    • Can you check the result? Can you check the argument?
    • Can you derive the solution differently? Can you see it at a glance?
    • Can you use the result, or the method, for some other problem?

Take bread

Take bread away from me, if you wish,
take air away, but
do not take from me your laughter-pablo neruda

Thursday, June 30, 2011

bad action

if you wish to discover the person behind a bad action, you must first try to find out who could benefit by it

Fight

Kings never fought themselves, but paid others to fight for them

Thursday, June 23, 2011

il Postino dialogs

Postman : I am in love
pablo neruda: There is a remedy for love
Postman: No,No, I want to stay sick
   -from il Postino

Your smiles spread like butterfly

Poetry does not belong to who write it.but those who need it.

Monday, June 20, 2011

KungFu Panda quotes

  • One often finds his destiny on the path he takes to avoid it.
  • [repeated lines] There are no accidents.
  • Your mind is like this water my friend, when it get's agitated it becomes difficult to see. But if you allow it to settle the answer becomes clear.
  • Quit. Don't quit. Noodles. Don't noodles. You are too concerned with what was and what will be. There's a saying. Yesterday is history, tomorrow is a mystery, but today is a gift. That is why it is called the "present".

KungFu panda quotes

The only thing that matters is what you choose to be now
Your story may not have such a happy beginning, but that doesn't make you who you are. it is the rest of your story, who you choose to be... So, who are you?



Wednesday, June 15, 2011

worth fighting for

"'The world is a fine place and worth fighting for.' I agree with the second part. " - Ernest Hemingway

Thursday, May 19, 2011

Solving Problems

We cannot solve the problems by the same way we created it

Wednesday, May 04, 2011

Quotes

"defeat is not when you fall down,It is when you refuse to get up" - "Alexander Great"

"STRUGGLE"
This 8 letter word will exhaust you, irritates you and some times demoralize you, but it gives an elegant reward called SUCCESS."

Quotes

http://www.jittery.com/quotes/book-quotes-c-1.html

Re: source of your energy

I am constantly critical of myself. And I am constantly competing
against myself since I don't measure myself against anyone. That way, there is no room for complacency.

-Vasanthi, RJ

On Wed, May 4, 2011 at 2:58 PM, sundar rajan <sundararajan.svks@gmail.com> wrote:
What is the source of your energy ?

Simple. I love what I do

-Vasanthi , RJ

source of your energy

What is the source of your energy ?

Simple. I love what I do

-Vasanthi , RJ

robert frost

"The
woods are lovely, dark and deep, But I have promises to keep; And miles
to go before I sleep, And miles to go before I sleep." - Robert Frost

Monday, March 07, 2011

Illegal stack operations

Illegal Stack Operations

Illegal stack operations can lead to hard to detect crashes. This typically takes place when a program passes a pointer of the wrong type to a function. The example given below shows a case of a function expecting an integer pointer and the caller passes a pointer to a character.

http://www.eventhelix.com/realtimemantra/Basics/debugging_software_crashes.htm

char pointer/int pointer mixup
main()
{
char count;
// The routine expects a int pointer but a char pointer has been passed
// Older compilers and non ANSI C compilers do not catch this error
GetCount(&count);
// The called function was expecting an int (say 4 byte) variable. It was
// however passed a char pointer with one byte space. GetCount will still
// write four bytes, thus corrupting local variables or parameters on the
// stack
}

bool GetCount(int *pCount)
{
. . .
*pCount = returnValue;
return true;
}

Monday, February 28, 2011

what these functions will do in socket programming [ htons(), htonl(), ntohs() and ntohl() ]

By Order of the Realm! There shall be two byte orderings, hereafter to be known as Lame and Magnificent!

I joke, but one really is better than the other. :-)

There really is no easy way to say this, so I'll just blurt it out: your computer might have been storing bytes in reverse order behind your back. I know! No one wanted to have to tell you.

The thing is, everyone in the Internet world has generally agreed that if you want to represent the two-byte hex number, say b34f, you'll store it in two sequential bytes b3 followed by 4f. Makes sense, and, as Wilford Brimley would tell you, it's the Right Thing To Do. This number, stored with the big end first, is called Big-Endian.

Unfortunately, a few computers scattered here and there throughout the world, namely anything with an Intel or Intel-compatible processor, store the bytes reversed, so b34f would be stored in memory as the sequential bytes 4f followed by b3. This storage method is called Little-Endian.

But wait, I'm not done with terminology yet! The more-sane Big-Endian is also called Network Byte Order because that's the order us network types like.

Your computer stores numbers in Host Byte Order. If it's an Intel 80x86, Host Byte Order is Little-Endian. If it's a Motorola 68k, Host Byte Order is Big-Endian. If it's a PowerPC, Host Byte Order is... well, it depends!

A lot of times when you're building packets or filling out data structures you'll need to make sure your two- and four-byte numbers are in Network Byte Order. But how can you do this if you don't know the native Host Byte Order?

Good news! You just get to assume the Host Byte Order isn't right, and you always run the value through a function to set it to Network Byte Order. The function will do the magic conversion if it has to, and this way your code is portable to machines of differing endianness.

All righty. There are two types of numbers that you can convert: short (two bytes) and long (four bytes). These functions work for the unsigned variations as well. Say you want to convert a short from Host Byte Order to Network Byte Order. Start with "h" for "host", follow it with "to", then "n" for "network", and "s" for "short": h-to-n-s, or htons() (read: "Host to Network Short").

It's almost too easy...

You can use every combination of "n", "h", "s", and "l" you want, not counting the really stupid ones. For example, there is NOT a stolh() ("Short to Long Host") function—not at this party, anyway. But there are:

htons()

host to network short

htonl()

host to network long

ntohs()

network to host short

ntohl()

network to host long

Basically, you'll want to convert the numbers to Network Byte Order before they go out on the wire, and convert them to Host Byte Order as they come in off the wire.

How to detect memory leaks in C/C++ program ?

Answer:
Let us first see, How malloc and free works.

int * p = (int*)malloc(sizeof(int));
//malloc allocates memory and returns address to p. Let us say memory address 1000 is returned by malloc.

while freeing the memory, we will make use of the same address.

free(p); //free the memory address pointed by p [ in our case the memory address is 1000]

To detect memory leaks in a multiple file:


The concept is we have to use a Linked List to store the every malloc information.

Let us say malloc() is called in 100th line in 1.C.

At the time of malloc, We need to store the following informations in a linked list.
1.address returned by the malloc() fn
2.CPP filename [To get the c/cpp filename, we can use _FILE_ macro which will gives the cpp filename]
3.Line number at which malloc is called [_LINE_ macro gives us the line number]

Whenever we are freeing the memory, we need to check the linked list whether memory to be freed is available in where we stored the malloc() information.
if it is available in a linked list, then we need to delete that particular node and then free the memory.

Ex:
1.cpp

Line No:50: int * p = malloc(sizeof(int));
Line No:70: int* q = malloc(sizeof(int));
End of the program:
free(q);
//we forget to free the p;

For the above program, we will create the linked list with two nodes to represent two malloc info in 1.cpp.
while freeing the memory, the address to be freed will be checked with the linked list. if any node in a linked list matches, then we will remove that entry.
At the end of the program,Linked list will contains information about whichever pointer is not freed from memory.

Reference:http://www.codeproject.com/KB/cpp/MemoryLeakDetectionIn_CPP.aspx

Wednesday, February 23, 2011

awesome usage of function pointers in android C/C++

I have observed some awesome usage of function pointers in android C/C++. My sample application similar to that code:

#include <conio.h>

void fn( void (*seekDoneCb)() )
{
    void (*mSeekDoneCb)() = seekDoneCb;   

    (*mSeekDoneCb)();    
}

void Seek()
{
    printf("Seek()fn Called");
}

int main(int argc, _TCHAR* argv[])
{
    fn(Seek);
    getch();
    return 0;
}

Output:Seek()fn Called

Tuesday, February 22, 2011

How Negative values are stored in system ????

How Negative values are stored in system ????

int a = -1;
printf("Value of a:%x",a );

what will be the result ??? Can you tell me the value of it ???

Is it possible to predict this value ??


Result is:

 Value of a:0xffff ffff

Yes it is possible to predict the value of it.

Reasoning:
 
   Every bit is on or off / binary coded system. In binary coded system,
the negative values can be represented in two ways:

   1.One's complement [convert the zeroes to ones and ones to zeroes]
   2.Two's complement [ Two complement = one's complement value + 1]   


                      value of  1: 0000 0001
 One's complement to represent -1: 1111 1110 [changing the zeroes and to 1s and ones to zeroes in 0000 0001]
 Two's complement value          : 1111 1111 [1111 1110 +1]   

 To represent -1, the values will be stored as 1111 1111  in memory.



In my system, size(int) is 4 bytes.
   
To represent value 1 in Hex: 0x00000001 [ single value represents 4 bits].
         Value 1 in binary  : 00000000 00000000 00000000 00000001
One's complement for -1 in binary: 11111111 11111111 11111111 11111110
       
Two's complement for -1 in binary: 11111111 11111111 11111111 11111111
Two's complement for -1 in Hex   : 0x ffff ffff [single digit represents 4 binary digits]

In the same way, we can try for different negative values too.


int a = -1;
printf("Value of a:%x",a );

what will be the result ??? Can you tell me the value of it ???

Is it possible to predict this value ??


Result is:

 Value of a:0xffff ffff

Yes it is possible to predict the value of it.

Reasoning:
 
   Every bit is on or off / binary coded system. In binary coded system,
the negative values can be represented in two ways:

   1.One's complement [convert the zeroes to ones and ones to zeroes]
   2.Two's complement [ Two complement = one's complement value + 1]   


                      value of  1: 0000 0001
 One's complement to represent -1: 1111 1110 [changing the zeroes and to 1s and ones to zeroes in 0000 0001]
 Two's complement value          : 1111 1111 [1111 1110 +1]   

 To represent -1, the values will be stored as 1111 1111  in memory.



In my system, size(int) is 4 bytes.
   
To represent value 1 in Hex: 0x00000001 [ single value represents 4 bits].
         Value 1 in binary  : 00000000 00000000 00000000 00000001
One's complement for -1 in binary: 11111111 11111111 11111111 11111110
       
Two's complement for -1 in binary: 11111111 11111111 11111111 11111111
Two's complement for -1 in Hex   : 0x ffff ffff [single digit represents 4 binary digits]

In the same way, we can try for different negative values too.

Saturday, January 15, 2011

Bsnl Broadband Connection setup in Ubuntu

Bsnl Broadband Connection setup in Ubuntu

We need to create a point to point protocol connection to make the modem interface active.
**Method I:
Connecting broadband through command-line-Bridge Mode
/* all ubuntu versions*/
Note: your modem must be set in bridge mode
Steps:
1. Open a terminal
2. Type sudo pppoeconf
3. Enter sudo password if prompted
4. A window with blue screen pops up notifying the devices that are found
5. Follow the on screen instructions and press yes till you reach the screen which asks you to enter username
6. Backspace to delete the text username and then enter the username your ISP has provided you with
7. Press yes again and then enter the password
8. Follow the instructions till it asks you "Do you want to start the connection at start up."
Give yes if you want.
9. After setup is complete you will be prompted with a message in the terminal
10. To start the connection type pon dsl-provider in the terminal
Now, your internet connection gets activated.

11. To terminate this connection type poff in terminal


**Method II:
Ubuntu 8.10(hardy) and 9.04(jaunty) users often face a problem
Problem:The network menu does not appear in System>Administration
The solutions are:
*Method I:
1. Goto Applications>Add/Remove
2. In Show, from the drop-down menu select All available applications
3. In Search tab: type network
4. In Application: check the box next to Network(configure network devices and connections)
5. Apply changes
/*To download this file you need active internet connection*/

*Method II:
1. Open a terminal
2. Type network-admin
3. If your Network Settings is not installed then it will ask you to type
sudo apt-get install network-admin
4. If there is an active internet connection the Network Settings will be installed and it can be located under System>Administration>Network


Now,coming to configuration of Bsnl broadband connection through Network Settings
Steps:
1. Switch off your modem
2. Open Network Settings dialog box form System>Administration>Network
3. Select Wired Connection and click on Properties
4. In the Connection Settings Menu select Static IP and type in the following values and save:

IP Address : 192.168.1.2
/*Assigning the Ethernet Card an IP different from that of the modem*/

Subnet Mask: 255.255.255.0
Gateway address: 192.168.1.1

/* The Modem is being made the default gateway*/

5. Switch on the Modem .
6. Open the Terminal and type sudo pppoeconf
7 .A window with blue screen appears notifying the devices found
8. Press yes till the screen appears that asks you to enter username
9. Backspace to delete the text username and then enter the username your ISP has provided you with
10. Press yes again and then enter the password

Now, your internet connection gets activated.

Note: To check the IP configuration open a terminal and type ifconfig ppp0
The IPV4 address, default gateway and subnet mask addresses are shown

From:
----------
 http://priyanka-nit.blogspot.com/2009/09/bsnl-broadband-connection-setup-in.html

Thursday, January 06, 2011

SUCCESS

Risk is my life.
Possible is my love.
Impossible is my aim.
Dangerous is my game.
Don't play with me.
Because "SUCCESS" is my name

Tuesday, January 04, 2011

limitations / possibilities

Stop thinking in terms of limitations and start thinking in terms of possibilities