CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C DETAILS
Question :
When should a far pointer be used?
Category C Interview Questions
Rating (4.5) By 55 users
Added on 10/22/2004
Views 13044
Rate it!
Answers:

Sometimes you can get away with using a small memory model in most of a given program. There might be just a few things that don?t fit in your small data and code segments. When that happens, you can use explicit far pointers and function declarations to get at the rest of memory. A far function can be outside the 64KB segment most functions are shoehorned into for a small-code model. (Often, libraries are declared explicitly far, so they?ll work no matter what code model the program uses.)
A far pointer can refer to information outside the 64KB data segment. Typically, such pointers are used with farmalloc() and such, to manage a heap separate from where all the rest of the data lives. If you use a small-data, large-code model, you should explicitly make your function pointers far.



In a segmented architecture computer, a far pointer is a pointer which includes a segment selector, making it possible to point to addresses outside of the current segment.

For example, in an Intel 8086, where an ordinary pointer is just a 16-bit offset within an implied segment, a far pointer has two parts: a 16-bit segment value and a 16-bit offset value. A linear address is obtained by shifting the binary segment value four times to the left, and then adding the offset value. Hence the effective address is 20 bits (actually 21-bit, which led to the address wraparound and the Gate A20). Comparison and arithmetic on far pointers are problematic: there are potentially 4096 different segment-offset address pairs that point to the same address. To compare two far pointers, they must first be converted (normalized) to their 20-bit linear representation.

On C compilers targeting the 8086 processor family, far pointers were declared using a non-standard far qualifier. For example, char far *p; defined a far pointer to a char. The difficulty of normalizing far pointers could be avoided with the non-standard huge qualifier.



 Posted by: bhavanam raja sekhar reddy    

Contact bhavanam raja sekhar reddy  Contact bhavanam raja sekhar reddy


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
Can the size of an array be declared at runtime?
View Answer
What is the heap?
View Answer
What is the difference between NULL and NUL?
View Answer
What is a ?null pointer assignment? error? What are bus errors, memory faults, and core dumps?
View Answer
How can you determine the size of an allocated portion of memory?
View Answer
Can math operations be performed on a void pointer?
View Answer
How do you print an address?
View Answer
Why should I prototype a function?
View Answer
What is a static function?
View Answer
Is it possible to execute code even after the program exits the main() function?
View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/999/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.62