Re: Interview Questions

From: Thomas Matthews (Thomas_MatthewsSpitsOnSpamBots_at_sbcglobal.net)
Date: 05/14/04


Date: Fri, 14 May 2004 14:49:47 GMT

Jatinder wrote:
> I 'm a professional looking for the job.In interview these questions
> were asked with some others which I answered.But some of them left
> unanswered.Plz help.
>
> Here are some questions on C/C++, OS internals?
> Q1 . What is the use of pointer to an array?
One can iterate through the array using a pointer.
One can pass the location of an element by just passing the pointer.
The array can be allocated during run-time, especially when the
size is unknown at run-time.

> Q2 . What is the use of array of pointers?
Multi-dimensional array.
Allows polymorphism for families of classes.
A convenient container for objects allocated during run-time.

> Q3 . What is the use of pointer to function ?
One can have an object associated with a function to process
that object, such as factories.
Another use is to map menu items with functions to process the
selection.
Allows for more generic algorithms, such as qsort (which allows
a pointer to a comparison function).

> Q4 . How to print through serial port? What is Flow Control(Xon,Xoff)
> ?
This depends on the platform and maybe the Operating System.
The "best" way to print through a serial port is to use operating
system functions.
The Flow Control characters, Xon and Xoff, are one method to turn
on (resume) or pause (stop) transmission across the serial channel.
See also ETX, STX, Request To Send (RTS) and DTS.

> Q5 . What is IOCTL Explain .
I believe this is a platform specific structure containing details
about an I/O device.

> Q6 . How to create an interrupt service routine in C?
This requires notifying your compiler that a function is an
ISR.

> Q7 . What are the internals of a schedular ?
Depends on the platform and operating system. Fundamentally,
a schedular dispatches processes according to a given scheme,
schedule or algorithm.

> Q8 . The static variables are declared in heap or stack ?
Neither, as the _standard_ C language does not require an
implementation to have a stack or heap. On many implementations
that use a heap and stack, static variables are not declared
on the stack or heap. They are allocated in the same area
as global variables. But this depends on the implementation.

-- 
Thomas Matthews
C++ newsgroup welcome message:
          http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq:   http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
          http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
     http://www.josuttis.com  -- C++ STL Library book


Relevant Pages

  • Re: Heap vs Stack
    ... other memory area. ... Does any limit exist upto which a stack or a heap can grow. ... feature of the operating system on the platform. ...
    (comp.unix.programmer)
  • Re: About stack size
    ... If a compiler uses a stack, the stack size depends on the memory ... Is the location of the stack or heap important to ... C++ Faq: http://www.parashift.com/c++-faq-lite ...
    (alt.comp.lang.learn.c-cpp)
  • Re: How to distinguish between heap/stack pointers
    ... >> How do I distinguish between a heap pointer and a stack pointer? ... C++ Faq: http://www.parashift.com/c++-faq-lite ...
    (comp.lang.cpp)
  • Re: If Macs have no spyware....
    ... >had made a complete code review of its operating system and removed all ... and writing new data into those memory locations would ... >but when the data exists on the stack, it can cause very large problems. ... >location that needs to be written in place of the correct execution ...
    (comp.sys.mac.advocacy)
  • Re: If Macs have no spyware....
    ... First you yammer about being a Mac advocate, then bad mouth me for dumping XP in favor of a Mac. ... Supposedly Microsoft had made a complete code review of its operating system and removed all the buffers which could overflow. ... the fundamental problem is that the basic architecture of Windows has two fatal flaws in its memory management and while these remain in the software the ad hoc patches will never be enough to make Windows a secure operating system. ... These problems are bad enough when dealing with data in the one routine but when the data exists on the stack, it can cause very large problems. ...
    (comp.sys.mac.advocacy)