Urgent !!!!! Please if possible give the explain about the program.

P

Pravin Shetty

Hello to All,
I have interview 2moro.I need to explain this code and
i'm not getting this properly.I don't know what to do?
Please help me.


Requirement:

1) Look at ansc_tso_interface.h, and understand the definitions of
ANSC_TIMER_SCHEDULER_OBJECT,
ANSC_TIMER_DESCRIPTOR_OBJECT
and ANSC_TDO_CLIENT_OBJECT
2) Read the function: AnscTsoCancelTimer. Explain the functions line
by line
in person. You don't need to write down anything.
3) Explain to me the relationship between the
ANSC_TIMER_DESCRIPTOR_OBJECT and ANSC_TIMER_SCHEDULER_OBJECT in
person.

/**********************************************************************

module: ansc_co_interface.h

For Advanced Networking Service Container (ANSC),
BroadWay Service Delivery System

---------------------------------------------------------------
description:
This wrapper file defines the base class data structure and
interface for the general Ansc Component Objects.
---------------------------------------------------------------
environment:
platform independent
---------------------------------------------------------------

**********************************************************************/


#ifndef _ANSC_CO_INTERFACE_
#define _ANSC_CO_INTERFACE_


/***********************************************************
GENERAL NSM FUNCTION OBJECT DEFINITION
***********************************************************/

/*
* Define some const values that will be used in the container object
definition.
*/
#define ANSC_COMPONENT_OBJECT_NAME
"abstractComponentObject"
#define ANSC_COMPONENT_OBJECT_ID 0xFFFFFFFF

/*
* Since we write all kernel modules in C (due to better performance
and lack of compiler support),
* we have to simulate the C++ object by encapsulating a set of
functions inside a data structure.
*/
typedef ANSC_HANDLE
(*PFN_ANSCCO_CREATE)
(
ANSC_HANDLE hContainerContext,
ANSC_HANDLE hOwnerContext,
ANSC_HANDLE hAnscReserved
);

typedef ANSC_STATUS
(*PFN_ANSCCO_REMOVE)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_ANSCCO_ENROLL_OBJECTS)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_ANSCCO_INITIALIZE)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_HANDLE
(*PFN_ANSCCO_GET_OWNER)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_ANSCCO_SET_OWNER)
(
ANSC_HANDLE hThisObject,
ANSC_HANDLE hOwner
);

typedef char*
(*PFN_ANSCCO_GET_NAME)
(
ANSC_HANDLE hThisObject
);

typedef ULONG
(*PFN_ANSCCO_GET_OID)
(
ANSC_HANDLE hThisObject
);

typedef ULONG
(*PFN_ANSCCO_GET_RID)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_ANSCCO_DISPATCH_EVENT)
(
ANSC_HANDLE hThisObject,
ANSC_HANDLE hEvent
);

/*
* The Component Objects are the extensions to the basic container.
Any software module that is
* shared between two or more extension objects or controller objects
shall be implemented as a
* Container Object. The container itself actually can leverage some
of functionalities provided
* by the Container Objects.
*/
#define ANSCCO_CLASS_CONTENT
\
/* start of object class content */
\
SINGLE_LINK_ENTRY Linkage;
\
ANSC_HANDLE hContainerContext;
\
ANSC_HANDLE hOwnerContext;
\
char Name[ANSC_OBJECT_NAME_SIZE];
\
ULONG Oid;
\
ULONG Rid;
\

\
PFN_ANSCCO_CREATE Create;
\
PFN_ANSCCO_REMOVE Remove;
\
PFN_ANSCCO_ENROLL_OBJECTS EnrollObjects;
\
PFN_ANSCCO_INITIALIZE Initialize;
\
PFN_ANSCCO_GET_OWNER GetOwner;
\
PFN_ANSCCO_SET_OWNER SetOwner;
\
PFN_ANSCCO_GET_NAME GetName;
\
PFN_ANSCCO_GET_OID GetOid;
\
PFN_ANSCCO_GET_RID GetRid;
\
PFN_ANSCCO_DISPATCH_EVENT DispatchEvent;
\
/* end of object class content */
\

typedef struct
_ANSC_COMPONENT_OBJECT
{
ANSCCO_CLASS_CONTENT
}
ANSC_COMPONENT_OBJECT, *PANSC_COMPONENT_OBJECT;

#define ACCESS_ANSC_COMPONENT_OBJECT(p) \
ACCESS_CONTAINER(p, ANSC_COMPONENT_OBJECT, Linkage)


#endif



/**********************************************************************

module: ansc_tso_interface.h

For Advanced Networking Service Container (ANSC),
BroadWay Service Delivery System

description:

This wrapper file defines all the platform-independent
functions and macros related to timer scheduling operation.

---------------------------------------------------------------
environment:

platform independent
revision:

10/14/01 initial revision.

**********************************************************************/


#ifndef _ANSC_TSO_INTERFACE_
#define _ANSC_TSO_INTERFACE_


/*
* This object is derived a virtual base object defined by the
underlying framework. We include the
* interface header files of the base object here to shield other
objects from knowing the derived
* relationship between this object and its base class.
*/
#include "ansc_co_interface.h"
#include "ansc_co_external_api.h"
#include "ansc_cover3_interface.h"
#include "ansc_cover3_external_api.h"


/***********************************************************
PLATFORM INDEPENDENT TIMER SCHEDULER OBJECT DEFINITION
***********************************************************/

/*
* Define some const values that will be used in the object mapper
object definition.
*/
#define ANSC_TSO_SCHEDULING_UNIT 10
#define ANSC_TSO_TASK_CLEANUP_TIME 5000

/*
* Since we write all kernel modules in C (due to better performance
and lack of compiler support),
* we have to simulate the C++ object by encapsulating a set of
functions inside a data structure.
*/
typedef ANSC_STATUS
(*PFN_TSO_RESET)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_TSO_SCHEDULE)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_TSO_START)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_TSO_STOP)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_TSO_REGISTER_TIMER)
(
ANSC_HANDLE hThisObject,
ANSC_HANDLE hTimerDescriptor
);

typedef ANSC_STATUS
(*PFN_TSO_CANCEL_TIMER)
(
ANSC_HANDLE hThisObject,
ANSC_HANDLE hTimerDescriptor
);

typedef ANSC_STATUS
(*PFN_TSO_SCHEDULE_TIMER)
(
ANSC_HANDLE hThisObject,
ANSC_HANDLE hTimerDescriptor
);

/*
* Most policy configuration information is stored and transmitted in
xml format. Compared to our
* proprietary al_store based configuration format, xml not only
provides more flexible and
* powerful hierarchical structure, it can also be translated into
other data format, such as html,
* very easily via XSLT (eXtensible Stylesheet Language
Transformation). This Xml Parser Object
* takes a xml-based data stream as input, and exposes a read/write
interface similar to al_store.
*/
#define ANSC_TIMER_SCHEDULER_CLASS_CONTENT
\
/* duplication of the base object class content */
\
ANSCCO_VER3_CLASS_CONTENT
\
/* start of object class content */
\
ULONG SchedulingUnit;
\
ANSC_HANDLE hCurInvokedTdo;
\
BOOL bStarted;
\

\
ANSC_EVENT SchedulerEvent;
\
ANSC_TS_LOCK SyncTsLock;
\
QUEUE_HEADER TdoQueue;
\
ANSC_LOCK TdoQueueLock;
\

\
PFN_TSO_RESET Reset;
\
PFN_TSO_SCHEDULE ScheduleTask;
\
PFN_TSO_START Start;
\
PFN_TSO_STOP Stop;
\

\
PFN_TSO_REGISTER_TIMER RegisterTimer;
\
PFN_TSO_CANCEL_TIMER CancelTimer;
\
PFN_TSO_SCHEDULE_TIMER ScheduleTimer;
\
/* end of object class content */
\

typedef struct
_ANSC_TIMER_SCHEDULER_OBJECT
{
ANSC_TIMER_SCHEDULER_CLASS_CONTENT
}
ANSC_TIMER_SCHEDULER_OBJECT, *PANSC_TIMER_SCHEDULER_OBJECT;

#define ACCESS_ANSC_TIMER_SCHEDULER_OBJECT(p) \
ACCESS_CONTAINER(p, ANSC_TIMER_SCHEDULER_OBJECT, Linkage)


/***********************************************************
PLATFORM INDEPENDENT TIMER DESCRIPTOR OBJECT DEFINITION
***********************************************************/

/*
* Define some const values that will be used in the object descriptor
object definition.
*/
#define ANSC_TIMER_TYPE_PERIODIC 1
#define ANSC_TIMER_TYPE_SPORADIC 2

/*
* Since we write all kernel modules in C (due to better performance
and lack of compiler support),
* we have to simulate the C++ object by encapsulating a set of
functions inside a data structure.
*/
typedef ANSC_HANDLE
(*PFN_TDO_GET_CONTEXT)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_TDO_SET_CONTEXT)
(
ANSC_HANDLE hThisObject,
ANSC_HANDLE hContext
);

typedef ULONG
(*PFN_TDO_GET_ULONG)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_TDO_SET_ULONG)
(
ANSC_HANDLE hThisObject,
ULONG ulValue
);

typedef BOOL
(*PFN_TDO_GET_BOOL)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_TDO_SET_BOOL)
(
ANSC_HANDLE hThisObject,
BOOL bValue
);

typedef ANSC_STATUS
(*PFN_TDO_ACQUIRE)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_TDO_RELEASE)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_TDO_START)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_TDO_STOP)
(
ANSC_HANDLE hThisObject
);

typedef ANSC_STATUS
(*PFN_TDO_INVOKE)
(
ANSC_HANDLE hThisObject
);

/*
* Many extension or feature objects need to perform some background
cleaning and maintenance work
* in any container environment. This type of work can be implemented
via separate low-priority
* tasks or periodic timer-based callback functions, depending on the
support of the underlying
* real-time operating system. From our previous experience, timer
callback implementation has more
* os-support than background task based approach.
*/
#define ANSC_TIMER_DESCRIPTOR_CLASS_CONTENT
\
/* duplication of the base object class content */
\
ANSCCO_CLASS_CONTENT
\
/* start of object class content */
\
ANSC_HANDLE hScheduler;
\
ANSC_HANDLE hClient;
\
ANSC_LOCK AccessLock;
\
ULONG StartTime;
\
ULONG TimerType;
\
ULONG Interval;
\
ULONG RelativeDelay;
\
ULONG CallCounter;
\
BOOL bScheduled;
\

\
PFN_TDO_GET_CONTEXT GetScheduler;
\
PFN_TDO_SET_CONTEXT SetScheduler;
\
PFN_TDO_GET_CONTEXT GetClient;
\
PFN_TDO_SET_CONTEXT SetClient;
\
PFN_TDO_GET_ULONG GetStartTime;
\
PFN_TDO_SET_ULONG SetStartTime;
\
PFN_TDO_GET_ULONG GetTimerType;
\
PFN_TDO_SET_ULONG SetTimerType;
\
PFN_TDO_GET_ULONG GetInterval;
\
PFN_TDO_SET_ULONG SetInterval;
\
PFN_TDO_GET_ULONG GetDelay;
\
PFN_TDO_SET_ULONG SetDelay;
\
PFN_TDO_GET_ULONG GetCallCounter;
\
PFN_TDO_SET_ULONG SetCallCounter;
\
PFN_TDO_GET_BOOL GetState;
\
PFN_TDO_SET_BOOL SetState;
\

\
PFN_TDO_ACQUIRE AcquireAccess;
\
PFN_TDO_RELEASE ReleaseAccess;
\
PFN_TDO_START Start;
\
PFN_TDO_STOP Stop;
\
PFN_TDO_INVOKE Invoke;
\
/* end of object class content */
\

typedef struct
_ANSC_TIMER_DESCRIPTOR_OBJECT
{
ANSC_TIMER_DESCRIPTOR_CLASS_CONTENT
}
ANSC_TIMER_DESCRIPTOR_OBJECT, *PANSC_TIMER_DESCRIPTOR_OBJECT;

#define ACCESS_ANSC_TIMER_DESCRIPTOR_OBJECT(p) \
ACCESS_CONTAINER(p, ANSC_TIMER_DESCRIPTOR_OBJECT, Linkage)


/***********************************************************
CLIENT OBJECT DEFINITION FOR ANSC TIMER DESCRIPTOR
***********************************************************/

/*
* Define some const values that will be used in the object mapper
object definition.
*/

/*
* Since we write all kernel modules in C (due to better performance
and lack of compiler support),
* we have to simulate the C++ object by encapsulating a set of
functions inside a data structure.
*/
typedef ANSC_STATUS
(*PFN_TDOCO_INVOKE)
(
ANSC_HANDLE hClient
);

/*
* Unlike the previous version of VPCom, in which the wrapper is part
of the container, the
* container is now 100% portable for different embedded platforms.
The os-specific wrapper has to
* be rewritten for each platform. The wrapper creates this wrapper
object during initialization
* and passes it to container.
*/
typedef struct
_ANSC_TDO_CLIENT_OBJECT
{
ANSC_HANDLE hClientContext;

PFN_TDOCO_INVOKE Invoke;
}
ANSC_TDO_CLIENT_OBJECT, *PANSC_TDO_CLIENT_OBJECT;


#endif


/**********************************************************************

caller: owner of this object

prototype:

ANSC_STATUS
AnscTsoCancelTimer
(
ANSC_HANDLE hThisObject,
ANSC_HANDLE hTimerDescriptor
);

description:

This function is called by external objects to cancel an
active
timer descriptor object.

argument: ANSC_HANDLE hThisObject
This handle is actually the pointer of this object
itself.

ANSC_HANDLE hTimerDescriptor
Specifies the timer descriptor object to be processed.

return: status of operation.

**********************************************************************/

ANSC_STATUS
AnscTsoCancelTimer
(
ANSC_HANDLE hThisObject,
ANSC_HANDLE hTimerDescriptor
)
{
ANSC_STATUS returnStatus =
ANSC_STATUS_SUCCESS;
PANSC_TIMER_SCHEDULER_OBJECT pMyObject =
(PANSC_TIMER_SCHEDULER_OBJECT )hThisObject;
PANSC_TIMER_DESCRIPTOR_OBJECT pTimerDescriptor =
(PANSC_TIMER_DESCRIPTOR_OBJECT)hTimerDescriptor;
PANSC_TIMER_DESCRIPTOR_OBJECT pNextTdo = NULL;
PSINGLE_LINK_ENTRY pSLinkEntry = NULL;
BOOL bWaitForInvoke = FALSE;

AnscAcquireLock(&pMyObject->TdoQueueLock);
pTimerDescriptor->AcquireAccess((ANSC_HANDLE)pTimerDescriptor);

if ( !pTimerDescriptor->GetState((ANSC_HANDLE)pTimerDescriptor) )
{
pTimerDescriptor->ReleaseAccess((ANSC_HANDLE)pTimerDescriptor);
AnscReleaseLock(&pMyObject->TdoQueueLock);

return ANSC_STATUS_SUCCESS;
}
else if ( pTimerDescriptor->GetScheduler((ANSC_HANDLE)pTimerDescriptor)
!= (ANSC_HANDLE)pMyObject )
{
pTimerDescriptor->ReleaseAccess((ANSC_HANDLE)pTimerDescriptor);
AnscReleaseLock(&pMyObject->TdoQueueLock);

return ANSC_STATUS_SUCCESS;
}

pSLinkEntry = AnscQueueGetNextEntry(&pTimerDescriptor->Linkage);

if ( pSLinkEntry )
{
pNextTdo = ACCESS_ANSC_TIMER_DESCRIPTOR_OBJECT(pSLinkEntry);

pNextTdo->RelativeDelay += pTimerDescriptor->RelativeDelay;
}

AnscQueuePopEntryByLink(&pMyObject->TdoQueue,
&pTimerDescriptor->Linkage);

pTimerDescriptor->SetState((ANSC_HANDLE)pTimerDescriptor, FALSE
);
pTimerDescriptor->SetDelay((ANSC_HANDLE)pTimerDescriptor,
pTimerDescriptor->GetInterval((ANSC_HANDLE)pTimerDescriptor));

if ( pMyObject->hCurInvokedTdo == (ANSC_HANDLE)pTimerDescriptor )
{
bWaitForInvoke = TRUE;
}

pTimerDescriptor->ReleaseAccess((ANSC_HANDLE)pTimerDescriptor);
AnscReleaseLock(&pMyObject->TdoQueueLock);

if ( bWaitForInvoke )
{
AnscAcquireTsLock(&pMyObject->SyncTsLock);
AnscReleaseTsLock(&pMyObject->SyncTsLock);
}

return ANSC_STATUS_SUCCESS;
}


with regards,

pravin
 
J

Joona I Palaste

Pravin said:
Hello to All,
I have interview 2moro.I need to explain this code and
i'm not getting this properly.I don't know what to do?
Please help me.

You posted a 680-line header file, most probably copied directly from
the interview test, and asked a question that sounds pretty much like
"could you answer these interview questions for me?". And you only have
one day left for the interview. To me it looks like you are trying to
get someone else to actually answer the questions, then supply the
ready-made answers at the interview and pretend you understand C code.
I would have given a shot at it but I decided I'm not particularly fond
of your l33t h4x0r sp33k like "2moro".
 
M

Martin Ambuhl

Pravin said:
Hello to All,
I have interview 2moro.

If you spell this way on any forms you fill out, kiss that job goodbye.

What the hell is this with posting 22K of code, anyway?
 
I

infobahn

Pravin said:
Hello to All,
I have interview 2moro.I need to explain this code and
i'm not getting this properly.I don't know what to do?

Cancel the interview.
 
R

Richard Bos

I have interview 2moro.I need to explain this code and
i'm not getting this properly.I don't know what to do?

Brush up on your burger flipping skills, you'll need them.

Good thing, too - lazy cogs, cheaters and abysmal planners shouldn't be
programmers.

Richard
 
R

Rufus V. Smith

Pravin Shetty said:
Hello to All,
I have interview 2moro.I need to explain this code and
i'm not getting this properly.I don't know what to do?
Please help me.

In addition to all the other suggestions you've gotten
on this thread, I imagine that if anyone at the company
finds you've posted their proprietary interview questions,
and especially source code, in this newsgroup, you may not
only be out on your keister, but may quite possibly be on
the wrong end of legal action.

but IANAL

Rufus
 
R

Randy Howard

Hello to All,
I have interview 2moro.

Hopefully it is for cabana boy, because if you spell like that
on the job, you won't keep anything else very long.
 
J

Jack Klein

Hello to All,
I have interview 2moro.I need to explain this code and
i'm not getting this properly.I don't know what to do?
Please help me.

It's a dumb attempt to write C++ code in C.

The result is not C++.

And it's not good C.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top