Monday, November 06, 2006

C program to count the number of bits set in an unsigned integer

/*
Program to count no. of bits in an unsigned integer
*/
#include
#include

void main( void )
{
unsigned int a = 15;
int count = 0;

while( a )
{
++count;
a = a & ( a - 1 );
}

clrscr();
printf( "Count is %d\n", count );
getch();
}

Thursday, June 15, 2006

BITWISE OPERATOINS

Refer:
http://graphics.stanford.edu/~seander/bithacks.html

Register Storage Class

register is used to define local variables that should be stored in a register instead of RAM. This means that the variable has a maximum size equal to the register size (usually one word) and cant have the unary '&' operator applied to it (as it does not have a memory location).
{
register int Miles;
}
Register should only be used for variables that require quick access - such as counters. It should also be noted that defining 'register' goes not mean that the variable will be stored in a register. It means that it MIGHT be stored in a register - depending on hardware and implimentation restrictions.

Duplicate Characters deletion - String Operation

String Operation
Duplicate Characters deletion
/*
Name: Duplicate Characters deletion
Copyright: StarSoft
Author: Vijayakumar M
Date: 28/04/06 11:14
Description: To Remove Duplicate
characters in a string.
*/
#include
#include
#include
main()
{
char string[40]="thats goods super star";
char *p= string;
int i, j;
printf( "%s\n", string );
for( i=0;i {
for( j=i+1; j {
if( string[i]==string[j])
*(p+j)='*';
}
}
printf( "%s\n", string );
for( i=0;i {
if( string[i] != '*' )
printf( "%c", string[i] );
}
   getch();
}

Which elements are stored in stack?

In computer science, a stack is a temporary abstract data type and data structure based on the principle of Last In First Out (LIFO).
Stacks are very widely and extensively used in modern computer systems, and are usually implemented through a combination of hardware and software features.

A stack-based computer system is one that stores temporary information primarily in stacks, rather than hardware CPU registers (a register-based computer system).

how to find give no is 2 power of n

f=( ( no & ( no-1 ) ) == 0 )

if( f == 1)
printf( "The Given Number is Power of %d", no );
else
printf( "The Given Number is not Power of %d", no );

BITWISE OPERATIONS

#define SET_BIT( _X_, _NO_ ) ( 1<<(_X_-1)) _NO_
#define RESET_BIT( _X_, _NO_ ) ~( ( 1<<(_X_-1) ) ) & _NO_
#define SWAP_BIT( _X_, _NO_ ) ( 1<<(_X_-1)) ^ _NO_

Standards Other than DVB

1. ATSC
The Advanced Television Systems Committee (ATSC) is the group that helped to develop the new digital television standard for the United States, also adopted by Canada, Mexico, and South Korea and being considered by other countries.It is intended to replace the NTSC system and produce wide screen 16:9 images up to 1920×1080 pixels in size—more than six times the display resolution of the earlier standard.
2. ISDBIntegrated Services Digital Broadcasting (ISDB) is the digital television (DTV) and digital audio broadcasting (DAB) format that Japan has created toallow radio and television stations there to convert to digital.
3. ARIB
The Association of Radio Industries and Businesses, commonly known as ARIB, is a standardization organization in Japan.
ARIB is designated as the center of promotion of the efficient use of the radio spectrum and designated frequency change support agency.
4. SBTVD
Brazilian Digital Television System is a proposed digital television standard for Brazil.

Wednesday, June 14, 2006

What is embedded system?

Electrical control system which is designed to perform predefined specific function with combination of computer hardware and software.

RISC processor

Acronym for Reduced Instruction Set Computer. A microprocessor that carries out fewer instructions than traditional microprocessors so that it can work more quickly.

Direct Memory Access( DMA )

A technique for transferring data from main memory(not only main memory any type of memory) to a device without passing it through the CPU.

What is teltext?

Teletext is an information retrieval service provided by television broadcast companies. Teletext pages can be viewed on television sets with suitable decoders. They offer a range of text-based information, usually including national, international and sporting news, weather and TV schedules. Subtitle (or closed caption) information is also transmitted in the teletext signal.

What is preemptive scheduler?

A scheduler that may switch between threads at any time.

Monday, March 20, 2006

Pointer: What this means? int * (*(*ptf)(int))(char)

How can you detect a Cycle in a Linked List?

Constraint 1 : List is read-only, and you cannot mark elements.
Constraint 2 : There is limited amount of memory
Constraint 3 : The list is arbitarily long

Catch Loops in Two Passes
O(n) time complexity
Simultaneously go through the list by ones (slow iterator) and by twos (fast iterator). If there is a loop the fast iterator will go around that loop twice as fast as the slow iterator. The fast iterator will lap the slow iterator within a single pass through the cycle. Detecting a loop is then just detecting that the slow iterator has been lapped by the fast iterator.

// Best solution
function boolean hasLoop(Node startNode){
Node slowNode = Node fastNode1 = Node fastNode2 = startNode;
while (slowNode && fastNode1 = fastNode2.next() && fastNode2 = fastNode1.next()){
if (slowNode == fastNode1 slowNode == fastNode2) return true;
slowNode = slowNode.next();
}
return false;
}

Sunday, March 19, 2006

Give Me a String at Random from THIS File

Constraint:
1) You can make only one sequential pass through the file.
2) You may not store any additional information like a table of offsets.

I would like to receive the answers from you all. After receiving answers from you i will post the answer.

PS: Seems this question also asked in Microsoft Inverview.

--------------------------------------------------------------------

Solution: ( Taken from a book, if anyone know best solution, please post comment )

The basic technique is to pick survivors, and recalculate as you go along. This is so com-putationally inefficient that it's easy to overlook. You open the file and save the first string. At this point you have one candidate string with a 100% probability of picking it. While remembering the first string, you read the next string. You now have two candidates, each with a 50% probability. Pick one of them,save it, and discard the other. Read the next string, and choose between that and the saved string,weighting your choice 33% toward the new string and 67% toward the survivor (which represents the winner of the previous two-way selection). Save the new survivor.

Keep on doing this throughout the entire file, at each step reading string N, and choosing between that(with probability 1/N) and the previous survivor, with probability (N - 1)/N. When you reach the endof the file, the current survivor is the string picked at random!

Determine if a Variable is Signed or Not?

I hope you thought the below answer:

if (Var >0 )
signed
else
un-signed.

If so, your answer is wrong. Because, once more check the question carefully. It is not asking variable value is signed/ signed or negative/ postive. It is asking type's sign.

Example, type 'char' it has both 'sighed char' and 'unsigned char'. How do we know? Thanks to the 2's complement, using which we can find it.

Before saying the way, let me explain that, we cant use function for this: why? because if we use function, the type of the variable is defined, but our purpose is to find for any given type. So, we use Macro for it.

If we use macro, we can find the sign type, in two cases:

If the argument is value: (thanks to 2's complement)
#define IS_SIGNED(__VAR__) ( ( __VAR__ > 0 ) && ( ~__VAR__ > 0 ) )

If the argument is type: (thanks to typecasting)
#define IS_SIGNED(__TYPE__) ( (__TYPE__)0 - 1 > 0 )

PS: This question is asked in a interivew for recruiting to Microsoft.

How is a Library Call Different from System Call?

Answer: Simply, Library calls are part of the language/ application, system calls are part of the Operating System.

How: A system call gets into the kernel by issuing a "trap" or interrupt.

Below is the versus between these two calls:

  1. Example, the C Library is same on every ANSI C implmentation. System calls are different in each OS.
  2. Library call is a call to a routine in a library. System call is a call to the kernel for a service.
  3. Library call are linked with user program. System call is an entry point to the OS.
  4. Library calls are executed in user address space. System calls are executed in kernel address space.
  5. Library calls are counted as part of "user" time. System calls are counted as part of the "system" time.
  6. Library calls has the lower overhead of the procedural call. System calls have higher overhead context switch to kernel and back.

Wednesday, February 01, 2006

DiSEqC


DiSEqC (Digital Satellite Equipment Control) is a special comunication protocol for use between a satellite receiver and a device such as a multi-dish switch or a small dish antenna rotor. It is compatible with the actuators used to rotate large C band dishes if used with a DiSEqC positioner. It relies only on the coaxial cable to transmit both bidirectional data/signals and power.

Applications of DiSEqC:DiSEqC 1.0 circuit max. 4 LNB`s




DiSEqC 1.0: 4 LNB's Separate Option/Position



Diseqc A = Position A Option A
Diseqc B = Position B Option A
Diseqc C = Position A Option B
Diseqc D = Position B Option B


DiSEqC 1.0 + 0/12 Volt: 8 LNB's



DiSEqC 1.0 + Toneburst + 0/12 Volt: 12 LNB's

Attitudes in the receiver menu:
LNB1 = DiSEqC A, 0 Volt, ToneBurst Sat A
LNB2 = DiSEqC A, 0 Volt, ToneBurst Sat B
LNB3 = DiSEqC B, 0 Volt, ToneBurst aus
LNB4 = DiSEqC C, 0 Volt, ToneBurst Sat A
LNB5 = DiSEqC C, 0 Volt, ToneBurst Sat B
LNB6 = DiSEqC D, 0 Volt, ToneBurst aus
LNB7 = DiSEqC A, 12 Volt, ToneBurst Sat A
and so on to LNB12.

DiSEqC 1.0 + Toneburst + 2 Tuner: 12 LNB's


DiSEqC 1.1: 16 LNB's


DiSEqC 1.1: 64 LNB's



DiSEqC 1.2 of 1.3 Motor : 1 LNB


DiSEqC 1.2: 10 LNB's without Motor


DiSEqC 1.0 + ToneBurst + DiSEqC 1.2 + 2 Tuner: 16 LNB's


DiSEqC 1.0 + 0/12 Volt + DiSEqC 1.2 or 1.3 Motor: 5 LNB's

Monday, January 23, 2006

Explanations of Digital Television Terms

What is free to view digital tv?

Free to view digital tv is a replacement technology for existing free-to-air analog services. It provides better picture quality and reception, plus a variety of new features that enhance the viewing experience.

The digital television industry in Australia is using the DVB-T standard, first developed in Europe, rather than the American-developed ATSC standard. DVB-T is proving to be a very high quality system and is being used in many countries around the world.

What benefits does free to view digital tv provide?
Free to view digital tv is a far more efficient and flexible transmission system than the current analog system. It allows broadcasters to offer viewers a range of new and different services.

Australian digital television features include:
  • 'Ghost free' reception
  • Widescreen 16:9 pictures
  • Standard Definition pictures (SD)
  • High Definition pictures (HD)
  • High quality audio and surround sound
  • Multi-channel programming on ABC and SBS
  • Closed Captioning of programs for the hearing impaired
  • Electronic Program Guides (EPGs) with 'now & next' program information for some channels
  • In selected markets, on-screen program guide channel with today's program information for Nine Network, Seven Network, Network Ten & SBS
  • In selected markets, HD demonstration channels
  • Multi-camera views and enhancements during selected programs

Can my 4:3 analog TV set display digital TV to its full effect?

No. You can view digital television on your 4:3 analog receiver with a digital tv set top box, but you will not be able to see widescreen pictures displayed to full effect. Some set-top boxes give you the option of viewing widescreen pictures in 'letterbox' format (black bars top and bottom) or 'centre cut' full screen format (with the 4:3 section 'cut out' of the 16:9 picture).


Why are digital TV pictures sharper than with analog TV?
Analog television can suffer from multipath interference, which results in a 'ghosted' picture on your screen.

Free to view digital tv is not affected by multipath interference and picture 'flutter'. So the digital result is a sharper, cleaner and clearer picture.

In areas of low signal strength, viewers of analog tv may experience 'snowy' pictures. Without adequate signal strength to the set top box, digital tv may not improve the viewing experience compared to analog.

Is audio better on digital television than on analog?
Yes. Australian television has traditionally been broadcast with FM stereo sound.

Digital television will be transmitted with MPEG digital stereo sound (the equivalent of CD quality) and/or Dolby Digital Sound (2, 4 or 5 channels), thereby providing markedly superior audio services.

Is digital television likely to cause interference?
Typically no. Digital television is not inherently prone to causing interference and is markedly superior to analog television in that respect. But the planning of channel allocations for digital television has entailed the occupation by digital television broadcasts of some channels formerly used for other purposes, eg, as output channels for VCRs.


What is widescreen?
Digital television will be broadcast in widescreen mode. Widescreen television has a different aspect ratio (ratio of width to height) than traditional analog. The aspect ratio of a widescreen is 16:9, while Australian viewers have been accustomed to viewing a 4:3 aspect ratio since television began in this country.

Widescreen will, in many cases, literally mean you see more of the picture. Most movies are currently made in 16:9 and are converted to 4:3 to allow us to watch them on television or video, so there is a lot of information that you don't see on your television that you would see in the cinema version of the film. Live sporting events will benefit in particular from the extra detail and wider frame.

For some time now television production has been converting to widescreen, both locally and overseas. Widescreen programming is becoming more readily available and will eventually become the global standard.

What is a digital tv set top box receiver?
A digital tv set top box receives and decodes digital terrestrial tv transmissions into a form suitable for display on analog television sets or other display devices, eg computer monitors or projection screens.

Analog television sets currently in use in Australia cannot display digital transmissions on their screens without being connected to such a digital tv set top box receiver.


What does a digital tv set top box do?
The capability of a digital tv set top box will depend upon its specifications.

A digital tv set top box, when connected to a 4:3 analog television set, will usually give viewers an improved signal, better picture quality and multichannelling. Some set-top boxes may also provide viewers with data casting services and video, audio and data enhancements.


What is an integrated digital television?
This is a television set with built-in digital tv capabilities to receive and display digital transmissions.

Integrated digital televisions (IDTV) are generally distinguished by wide screens, high-level audio capability and high quality displays. They will not require a digital tv set top box for video and audio services.


What are Standard Definition (SD) pictures?
SD picture quality is superior to that obtained from analog 4:3 sets, and is 'ghost free' and in widescreen format.

The SD picture resolution is 576 lines x 720 pixels @ 50Hz interlaced (576i).


What are High Definition (HD) pictures?

HD pictures have image resolution which is superior to SD pictures and to the existing analog, with up to three times the improvement in detail.

Australian broadcasters are using two different levels of high definition;

– 1920 pixels x 1080 lines @ 50Hz interlaced

– 720 pixels x 576 lines @ 50Hz progressive


The benefits of HD pictures at the highest resolution are particularly noticeable on larger screen sets and when using projection equipment.

HD pictures are also ghost free and in widescreen format. When viewed on an HDTV screen the viewer can enjoy cinema-quality viewing with Dolby Digital sound (some HD programs).

Commercial free to air broadcasters are required to transmit a minimum of 1040 hours of 'native' HD programs (including advertisements) each year. In regional areas this is a requirement after two years from the commencement of digital tv transmissions in an area. Programs transmitted in High Definition will also be simultaneously broadcast in Standard Definition.


What is multi-view?

Multi-view lets you select from a variety of camera angles or may provide additional information related to an event. Multi-view is particularly suited to sporting events like cricket, tennis and motor racing.

On additional channels to the main program the viewer can select, via remote control, a different full screen views of the event, alternative audio commentary or related information.


What is multichannelling?
Because a digital signal can carry much more data than an analog signal, more than one channel of television programs can be broadcast in SDTV at the same time. This is known as multichannelling.

The Federal Government has decided that commercial broadcasters are not allowed to multichannel, but that the ABC and SBS may do so.

The ABC and SBS are allowed to broadcast, in addition to their main services, a wide range of programs including educational programs, regional news and current affairs, science and arts programs, children's programs, subtitled foreign programs, foreign language news and occasional dramas.

The ABC and SBS are able to transmit their radio services through their television channels, extending the reach of these services. The ABC also broadcasts its internet radio service - DiG - via digital television.

Broadcasters are also offering a number of program guide and information data channels and some are providing High Definiton demonstration channels.


What are program enhancements?
Viewers of digital television will have a wide choice of 'enhancements' to regular programming. Enhancements are separate channels of video, data or audio, which are related to the program on the primary channel.

Sports programs may offer the choice of a different camera angle, altenative audio commentary, action replays, player profiles or other information.


What is Closed Captioning?
Closed captioning provides deaf and hearing-impaired viewers with the text of what is being spoken on television. The text is usually shown in a black box at the bottom of the picture. Hearing-impaired viewers will be familiar with current analog captioning which can be received on analog receivers with teletext capability. Captioning is normally 'closed' to viewers but can be accessed by those who need it.

Closed captioning does not interfere with normal viewing.

The Australia digital terrestrial television (DTT) receiver standard is non-mandatory but currently says that all receivers should have closed captioning decoding capability, including the ability to -

(a) decode and display teletext page 801 closed captioning,
(b) decode and display DVB bitmapped Subtitles - (a different system used in some other countries but not by Australian broadcasters), and
(c) pass teletext closed caption data out on the SD video output in the VBI (Vertical Blanking Interval) so that a standard PAL receiver fitted with teletext decoding can display it.

As captions are currently provided in the teletext style with all Australian broadcasters’ prime time programs, this is the more important digital set top box (STB) capability to those viewers who wish to see closed captions.

Many digital STBs have teletext closed captioning display capabilities - with these STBs, a TV connected to them doesn't also need to be able to decode teletext closed captions, as the feature is provided by the STB.

There are some digital STBs that do not include closed captioning decoding and display capability. However a few of these do pass the closed caption data out on the video output (via the VBI - see (c) above), and when these STBs are connected to a standard teletext-capable TV set, access to the closed captions can be had by viewers.

Therefore, any consumer intending to purchase a DTT STB and use closed captioning should, before purchase, check on the STB's capabilities.

Closed captioning of programming is incorporated in all English language news and current affairs programs as well as for all prime time programs (6.00pm to 10.30pm).

Of course, when available, closed captions can continue to be viewed on a standard PAL teletext-capable TV set that is tuned to analog broadcasts. However, many more digital TV programs incorporate closed captioning than do analog TV programs.



What is an EPG (Electronic Program Guide)?
An EPG is the electronic version of a printed program guide. Using your remote control you will be able to see on-screen "what's on now" and "what's on next" for all free-to-air services. You may also be able to search for a particular program by theme or category, eg sporting programs, movies etc. Extra text and picture information (eg story line, episode description etc) can be called up as well. The EPG is always up-to-date and available at the click of a remote control button.


What is interactive television (iTV)?
iTV allows the viewer to receive more information from television broadcast than analog can provide. iTV can be one-way (unconnected) or two-way (connected).

One-way iTV delivers information to your receiver that is additional to the main program and that allows you the option to view it or not. The viewer is able to view travel deals, concert dates etc.

Full, two-way iTV enables you to send information back to the broadcaster via a back channel. The viewer is able to vote in a poll, reserve concert tickets, etc.

Both one-way and two-way iTV can be added to commercials as well as programs.

A special icon will appear on the screen to notify the viewer iTV is available.

Currently no interactive tv enhancements are available on free to view digital tv.

courtesy : Had some doubts about Digital tv ..searched net got the above..did CCP