DSPRelated.com
Forums

DSP/BIOS Task compile issue

Started by balasubramanian vaidhyanathan September 24, 2008
I got my trial project to compile... Only because my file name was .cpp and i changed to .c it compiled.... i find this strange in DSP/BIOS... Has anyone faced this issue before?
When you couldn't get your project to compile, was it giving you errors,
or was it simply ignoring your code?

I seem to remember something like this from when I was starting with the
TI compiler. I am pretty sure I set a flag to cause it to recognize the
.cpp extension as a c++ file. The extension used for recognizing a C++
code file varied between compilers for a long time. Many recognized .cc
or .C while using .c for standard C code.

balasubramanian vaidhyanathan wrote:
> I got my trial project to compile... Only because my file name was
> .cpp and i changed to .c it compiled.... i find this strange in
> DSP/BIOS... Has anyone faced this issue before?
Hi

Below is the code I yanked out of TI BIOS User guide. Now what i cant understand is this, the writer task has an id. In the document it says there are three writers. So does that mean i have to create three tasks and connect them to _writer and give same priority and run this code so that i can have 3 writers?. I tried running with 2 writers and the code does not behave as told. I ran with only one task and in the reader() task i removed the 2 in the loop and the code exited properly. Please explain.I have highlighted my confusing points in bold....

regards
Bala

#include
#include
#include
#include
#include
#include
#include "queuecfg.h"
#define NUMMSGS 3 /* number of messages */
#define NUMWRITERS 3
typedef struct MsgObj {
QUE_Elem elem; /* first field for QUE */
int id;
Char val; /* message value */
} MsgObj, *Msg;

/*
* ======== main =======*/
Void main()
{
int i;
MsgObj *msg;
Uns mask;
mask=TRC_LOGTSK|TRC_LOGSWI|TRC_STSSWI|TRC_LOGCLK;
TRC_enable(TRC_GBLHOST|TRC_GBLTARG|mask);
msg=(MsgObj *)MEM_alloc(0,NUMMSGS*sizeof(MsgObj),0);
if(msg==MEM_ILLEGAL)
{
SYS_abort("Memory allocation failed \n");
}
for(i=0;i {
QUE_put(&freeQueue,msg);
}
}
/* reader code */
void reader()
{
Msg msg;
Int i;
for(i=0;i {
SEM_pend(&sem,SYS_FOREVER);
msg=QUE_get(&msgQueue);
LOG_printf(&trace,"read '%c' from (%d) .",msg->val,msg->id);
QUE_put(&freeQueue,msg);
}
LOG_printf(&trace,"reader done\n");
}

/* writer code */
void writer(Int id)
{
Msg msg;
Int i;

for(i=0;i {
/* Get msg from the free queue*/
if(QUE_empty(&freeQueue))
{

SYS_abort("Empty free queue\n");
}
msg=QUE_get(&freeQueue);
/*fill in value*/
msg->id=id;
msg->val=(i& 0xf)+'a';
LOG_printf(&trace,"(%d) writing '%c'...",id,msg->val);
QUE_put(&msgQueue,msg);
SEM_post(&sem);
}
LOG_printf(&trace,"Writer is done\n");
}

--- On Wed, 9/24/08, William C Bonner wrote:

From: William C Bonner
Subject: Re: [c6x] DSP/BIOS Task compile issue
To: "balasubramanian vaidhyanathan"
Cc: c...
Date: Wednesday, September 24, 2008, 11:04 AM

When you couldn't get your project to compile, was it giving you errors,
or was it simply ignoring your code?

I seem to remember something like this from when I was starting with the
TI compiler. I am pretty sure I set a flag to cause it to recognize the
.cpp extension as a c++ file. The extension used for recognizing a C++
code file varied between compilers for a long time. Many recognized .cc
or .C while using .c for standard C code.

balasubramanian vaidhyanathan wrote:
> I got my trial project to compile... Only because my file name was
> .cpp and i changed to .c it compiled.... i find this strange in
> DSP/BIOS... Has anyone faced this issue before?
How does one pass arguments to a task.... Like in the writer reader example in TI DSP/BIOS user guide page 4.53 using queues and semaphores I want the write task to take different id's.. Is it different tasks that i shud configure in cdb file?. I did that still it did not happen when i printed out the id value..... can you clarify?
--- On Wed, 9/24/08, William C Bonner wrote:

From: William C Bonner
Subject: Re: [c6x] DSP/BIOS Task compile issue
To: "balasubramanian vaidhyanathan"
Cc: c...
Date: Wednesday, September 24, 2008, 11:04 AM

When you couldn't get your project to compile, was it giving you errors,
or was it simply ignoring your code?

I seem to remember something like this from when I was starting with the
TI compiler. I am pretty sure I set a flag to cause it to recognize the
.cpp extension as a c++ file. The extension used for recognizing a C++
code file varied between compilers for a long time. Many recognized .cc
or .C while using .c for standard C code.

balasubramanian vaidhyanathan wrote:
> I got my trial project to compile... Only because my file name was
> .cpp and i changed to .c it compiled.... i find this strange in
> DSP/BIOS... Has anyone faced this issue before?
balasub...

Here is a usable version of the code.
I have not had a chance to run it, so cannot assure no keypunch errors.

I suggest you read the TI document: spru625i.pdf
"TMS320C28x DSP/BIOS 5.32
Application Programming Interface
(API) Reference Guide"

As it clearly states what needs to be done to perform the task you are trying to
perform.

=============================#include

#include
#include
#include
#include
#include

#include "queuecfg.h"

#define NUMMSGS 3 /* number of messages */
#define NUMWRITERS 3

typedef struct MsgObj {
QUE_Elem elem; /* first field for QUE */
int id;
Char val; /* message value */
} Msg_Obj;
struct QUE_Obj *pQUE_Handle;
struct QUE_Attrs{ /* queue atributes */
Int dummy; /* dummy */
};
QUE_Attrs QUE_ATTRS = {0}; /* default attribute values */

/*
* ======== main =======*/
Void main()
{
int i;
Uns mask;

mask=TRC_LOGTSK|TRC_LOGSWI|TRC_STSSWI|TRC_LOGCLK;
TRC_enable(TRC_GBLHOST|TRC_GBLTARG|mask); // get everything going

// create the queue, used QUE_Handle rather than freeQueue
pQUE_Handle = QUE_create( &QUE_ATTRS )
return;
} /* end of function: main() */
/* reader code */
void reader()
{
Msg_Obj *reader_pMsg;
Int i;

for i=0; i {
SEM_pend(&sem,SYS_FOREVER); // wait for message to be available

if ((QUE_Obj)(reader_pMsg = QUE_get(pQUE_Handle)) != pQUE_Handle)
{ // then, queue not empty
reader_pMsg = QUE_get(pQUE_Handle);
// get ptr to msg at tail of freeQueue
// also moves freeQueue tail
// to next entry

LOG_printf(&trace,"read '%c' from (%d) .",
reader_pMsg->val,
reader_pMsg->id);
} // endif(queue not empty)
} // endfor()

LOG_printf(&trace,"reader done\n");
return;
} /* end of function: reader() */
/* writer code */
void writer(Int id)
{
Msg_Obj writer_Msg; // area to create new message(s)
Int i; // loop counter

for(i=0; i // put NUMMSGS new messages into queue
// each message put at new head of queue
{
/*fill in values */
writer_Msg->id=id;
writer_Msg->val=(i& 0xf)+'a';

LOG_printf(&trace,"(%d) writing '%c'...",
id,
writer_Msg->val);

QUE_put(pQUE_Handle, &writer_Msg);
// copies local message area
// to head of pQUE_Handle queue
// and increments the head to
// the next entry in queue

SEM_post(&sem);
// indicate another MsgObj available queue
} // endfor()

LOG_printf(&trace,"Writer is done\n");
return;
} /* end of function: writer() */
-------------------------------

---------- Original Message -----------
From: balasubramanian vaidhyanathan
To: William C Bonner
Cc: c...
Sent: Wed, 24 Sep 2008 15:13:18 -0700 (PDT)
Subject: [c6x] Issue understanding this code

> Hi
>
> Below is the code I yanked out of TI BIOS User guide. Now what i
> cant understand is this, the writer task has an id. In the document it
> says there are three writers. So does that mean i have to create three
> tasks and connect them to _writer and give same priority and run this
> code so that i can have 3 writers?. I tried running with 2 writers and
> the code does not behave as told. I ran with only one task and in the
> reader() task i removed the 2 in the loop and the code exited
> properly. Please explain.I have highlighted my confusing points in bold....
>
> regards
> Bala
>
> #include
> #include
> #include
> #include
> #include
> #include
> #include "queuecfg.h"
> #define NUMMSGS 3 /* number of messages */
> #define NUMWRITERS 3
> typedef struct MsgObj {
> QUE_Elem elem; /* first field for QUE */
> int id;
> Char val; /* message value */
> } MsgObj, *Msg;
>
> /*
> * ======== main =======> */
> Void main()
> {
> int i;
> MsgObj *msg;
> Uns mask;
> mask=TRC_LOGTSK|TRC_LOGSWI|TRC_STSSWI|TRC_LOGCLK;
> TRC_enable(TRC_GBLHOST|TRC_GBLTARG|mask);
> msg=(MsgObj *)MEM_alloc(0,NUMMSGS*sizeof(MsgObj),0);
> if(msg==MEM_ILLEGAL)
> {
> SYS_abort("Memory allocation failed \n");
> }
> for(i=0;i > {
> QUE_put(&freeQueue,msg);
> }
> }
> /* reader code */
> void reader()
> {
> Msg msg;
> Int i;
> for(i=0;i > {
> SEM_pend(&sem,SYS_FOREVER);
> msg=QUE_get(&msgQueue);
> LOG_printf(&trace,"read '%c' from (%d) .",msg->val,msg->id);
> QUE_put(&freeQueue,msg);
> }
> LOG_printf(&trace,"reader done\n");
> }
>
> /* writer code */
> void writer(Int id)
> {
> Msg msg;
> Int i;
>
> for(i=0;i > {
> /* Get msg from the free queue*/
> if(QUE_empty(&freeQueue))
> {
>
> SYS_abort("Empty free queue\n");
> }
> msg=QUE_get(&freeQueue);
> /*fill in value*/
> msg->id=id;
> msg->val=(i& 0xf)+'a';
> LOG_printf(&trace,"(%d) writing '%c'...",id,msg->val);
> QUE_put(&msgQueue,msg);
> SEM_post(&sem);
> }
> LOG_printf(&trace,"Writer is done\n");
> }
>
> --- On Wed, 9/24/08, William C Bonner wrote:
>
> From: William C Bonner
> Subject: Re: [c6x] DSP/BIOS Task compile issue
> To: "balasubramanian vaidhyanathan"
> Cc: c...
> Date: Wednesday, September 24, 2008, 11:04 AM
>
> When you couldn't get your project to compile, was it giving you
> errors, or was it simply ignoring your code?
>
> I seem to remember something like this from when I was starting with
> the TI compiler. I am pretty sure I set a flag to cause it to
> recognize the .cpp extension as a c++ file. The extension used for
> recognizing a C++ code file varied between compilers for a long time.
> Many recognized .cc or .C while using .c for standard C code.
>
> balasubramanian vaidhyanathan wrote:
> > I got my trial project to compile... Only because my file name was
> > .cpp and i changed to .c it compiled.... i find this strange in
> > DSP/BIOS... Has anyone faced this issue before?
> >
> >
------- End of Original Message -------
balasub,,,
I ran the code, I now see why the 'freeQueue' was being initialized with
pointer to messages/
I.E.
The QUE_Get() and QUE_Put() only transfer a pointer to a message, rather than
the actual message content.

So I am wrong in the elimination of the freeQueue.
Sorry about that.
BTW:
The code is also missing the following, probably just after the #include statements:
void reader(void); // declaration for the reader task
void writer(Int taskId); // declaration for the writer task

The code is missing the following statements:
extern SEM_Obj sem;
extern QUE_Obj msgQueue;
extern QUE_Obj freeQueue;
extern LOG_Obj trace;

And each of the writer_Msg variables that I wrote, need to be changed to a
pointer, etc.

If you want, I can send along a more realistic version.

R. Williams

---------- Original Message -----------
From: balasubramanian vaidhyanathan
To: William C Bonner
Cc: c...
Sent: Wed, 24 Sep 2008 15:13:18 -0700 (PDT)
Subject: [c6x] Issue understanding this code

> Hi
>
> Below is the code I yanked out of TI BIOS User guide. Now what i
> cant understand is this, the writer task has an id. In the document it
> says there are three writers. So does that mean i have to create three
> tasks and connect them to _writer and give same priority and run this
> code so that i can have 3 writers?. I tried running with 2 writers and
> the code does not behave as told. I ran with only one task and in the
> reader() task i removed the 2 in the loop and the code exited
> properly. Please explain.I have highlighted my confusing points in bold....
>
> regards
> Bala
>
> #include
> #include
> #include
> #include
> #include
> #include
> #include "queuecfg.h"
> #define NUMMSGS 3 /* number of messages */
> #define NUMWRITERS 3
> typedef struct MsgObj {
> QUE_Elem elem; /* first field for QUE */
> int id;
> Char val; /* message value */
> } MsgObj, *Msg;
>
> /*
> * ======== main =======> */
> Void main()
> {
> int i;
> MsgObj *msg;
> Uns mask;
> mask=TRC_LOGTSK|TRC_LOGSWI|TRC_STSSWI|TRC_LOGCLK;
> TRC_enable(TRC_GBLHOST|TRC_GBLTARG|mask);
> msg=(MsgObj *)MEM_alloc(0,NUMMSGS*sizeof(MsgObj),0);
> if(msg==MEM_ILLEGAL)
> {
> SYS_abort("Memory allocation failed \n");
> }
> for(i=0;i > {
> QUE_put(&freeQueue,msg);
> }
> }
> /* reader code */
> void reader()
> {
> Msg msg;
> Int i;
> for(i=0;i > {
> SEM_pend(&sem,SYS_FOREVER);
> msg=QUE_get(&msgQueue);
> LOG_printf(&trace,"read '%c' from (%d) .",msg->val,msg->id);
> QUE_put(&freeQueue,msg);
> }
> LOG_printf(&trace,"reader done\n");
> }
>
> /* writer code */
> void writer(Int id)
> {
> Msg msg;
> Int i;
>
> for(i=0;i > {
> /* Get msg from the free queue*/
> if(QUE_empty(&freeQueue))
> {
>
> SYS_abort("Empty free queue\n");
> }
> msg=QUE_get(&freeQueue);
> /*fill in value*/
> msg->id=id;
> msg->val=(i& 0xf)+'a';
> LOG_printf(&trace,"(%d) writing '%c'...",id,msg->val);
> QUE_put(&msgQueue,msg);
> SEM_post(&sem);
> }
> LOG_printf(&trace,"Writer is done\n");
> }
>
> --- On Wed, 9/24/08, William C Bonner wrote:
>
> From: William C Bonner
> Subject: Re: [c6x] DSP/BIOS Task compile issue
> To: "balasubramanian vaidhyanathan"
> Cc: c...
> Date: Wednesday, September 24, 2008, 11:04 AM
>
> When you couldn't get your project to compile, was it giving you
> errors, or was it simply ignoring your code?
>
> I seem to remember something like this from when I was starting with
> the TI compiler. I am pretty sure I set a flag to cause it to
> recognize the .cpp extension as a c++ file. The extension used for
> recognizing a C++ code file varied between compilers for a long time.
> Many recognized .cc or .C while using .c for standard C code.
>
> balasubramanian vaidhyanathan wrote:
> > I got my trial project to compile... Only because my file name was
> > .cpp and i changed to .c it compiled.... i find this strange in
> > DSP/BIOS... Has anyone faced this issue before?
> >
> >
------- End of Original Message -------
Hi,

How do i get the LOG to show three writers here.I cant understand how the Id is passed... Can you throw some light on this?... I understand there are three writers in that example... When i see the logs i see the id being 1 always in my LOGs but in the example in the document they show different ids... How are the Ids to the writer passed...


--- On Wed, 9/24/08, Richard Williams wrote:

From: Richard Williams
Subject: Re: [c6x] Issue understanding this code
To: i...@yahoo.com, "William C Bonner"
Cc: c...
Date: Wednesday, September 24, 2008, 11:32 PM

balasub,,,
I ran the code, I now see why the 'freeQueue' was being initialized
with
pointer to messages/
I.E.
The QUE_Get() and QUE_Put() only transfer a pointer to a message, rather than
the actual message content.

So I am wrong in the elimination of the freeQueue.
Sorry about that.
BTW:
The code is also missing the following, probably just after the #include
statements:
void reader(void); // declaration for the reader task
void writer(Int taskId); // declaration for the writer task

The code is missing the following statements:
extern SEM_Obj sem;
extern QUE_Obj msgQueue;
extern QUE_Obj freeQueue;
extern LOG_Obj trace;

And each of the writer_Msg variables that I wrote, need to be changed to a
pointer, etc.

If you want, I can send along a more realistic version.

R. Williams

---------- Original Message -----------
From: balasubramanian vaidhyanathan
To: William C Bonner
Cc: c...
Sent: Wed, 24 Sep 2008 15:13:18 -0700 (PDT)
Subject: [c6x] Issue understanding this code

> Hi
>
> Below is the code I yanked out of TI BIOS User guide. Now what i
> cant understand is this, the writer task has an id. In the document it
> says there are three writers. So does that mean i have to create three
> tasks and connect them to _writer and give same priority and run this
> code so that i can have 3 writers?. I tried running with 2 writers and
> the code does not behave as told. I ran with only one task and in the
> reader() task i removed the 2 in the loop and the code exited
> properly. Please explain.I have highlighted my confusing points in
bold....
>
> regards
> Bala
>
> #include
> #include
> #include
> #include
> #include
> #include
> #include "queuecfg.h"
> #define NUMMSGS 3 /* number of messages */
> #define NUMWRITERS 3
> typedef struct MsgObj {
> QUE_Elem elem; /* first field for QUE */
> int id;
> Char val; /* message value */
> } MsgObj, *Msg;
>
> /*
> * ======== main ========
> */
> Void main()
> {
> int i;
> MsgObj *msg;
> Uns mask;
> mask=TRC_LOGTSK|TRC_LOGSWI|TRC_STSSWI|TRC_LOGCLK;
> TRC_enable(TRC_GBLHOST|TRC_GBLTARG|mask);
> msg=(MsgObj *)MEM_alloc(0,NUMMSGS*sizeof(MsgObj),0);
> if(msg==MEM_ILLEGAL)
> {
> SYS_abort("Memory allocation failed \n");
> }
> for(i=0;i > {
> QUE_put(&freeQueue,msg);
> }
> }
> /* reader code */
> void reader()
> {
> Msg msg;
> Int i;
> for(i=0;i > {
> SEM_pend(&sem,SYS_FOREVER);
> msg=QUE_get(&msgQueue);
> LOG_printf(&trace,"read '%c' from (%d)
.",msg->val,msg->id);
> QUE_put(&freeQueue,msg);
> }
> LOG_printf(&trace,"reader done\n");
> }
>
> /* writer code */
> void writer(Int id)
> {
> Msg msg;
> Int i;
>
> for(i=0;i > {
> /* Get msg from the free queue*/
> if(QUE_empty(&freeQueue))
> {
>
> SYS_abort("Empty free queue\n");
> }
> msg=QUE_get(&freeQueue);
> /*fill in value*/
> msg->id=id;
> msg->val=(i& 0xf)+'a';
> LOG_printf(&trace,"(%d) writing
'%c'...",id,msg->val);
> QUE_put(&msgQueue,msg);
> SEM_post(&sem);
> }
> LOG_printf(&trace,"Writer is done\n");
> }
>
> --- On Wed, 9/24/08, William C Bonner wrote:
>
> From: William C Bonner
> Subject: Re: [c6x] DSP/BIOS Task compile issue
> To: "balasubramanian vaidhyanathan"

> Cc: c...
> Date: Wednesday, September 24, 2008, 11:04 AM
>
> When you couldn't get your project to compile, was it giving you
> errors, or was it simply ignoring your code?
>
> I seem to remember something like this from when I was starting with
> the TI compiler. I am pretty sure I set a flag to cause it to
> recognize the .cpp extension as a c++ file. The extension used for
> recognizing a C++ code file varied between compilers for a long time.
> Many recognized .cc or .C while using .c for standard C code.
>
> balasubramanian vaidhyanathan wrote:
> > I got my trial project to compile... Only because my file name was
> > .cpp and i changed to .c it compiled.... i find this strange in
> > DSP/BIOS... Has anyone faced this issue before?
> >
> >
------- End of Original Message -------

balasub...

In the BIOS configuration, where the tasks are documented, there is a section on
passed parameters.
*I think* that is where the task/thread number would be passed.

R. Williams
---------- Original Message -----------
From: balasubramanian vaidhyanathan
To: Richard Williams
Cc: c...
Sent: Thu, 25 Sep 2008 07:24:17 -0700 (PDT)
Subject: Re: [c6x] Issue understanding this code

> Hi,
>
> How do i get the LOG to show three writers here.I cant understand
> how the Id is passed... Can you throw some light on this?... I
> understand there are three writers in that example... When i see the
> logs i see the id being 1 always in my LOGs but in the example in the
> document they show different ids... How are the Ids to the writer passed...
>
>
> --- On Wed, 9/24/08, Richard Williams wrote:
>
> From: Richard Williams
> Subject: Re: [c6x] Issue understanding this code
> To: i...@yahoo.com, "William C Bonner"
> Cc: c...
> Date: Wednesday, September 24, 2008, 11:32 PM
>
> balasub,,,
>
> I ran the code, I now see why the 'freeQueue' was being initialized
> with
> pointer to messages/
> I.E.
> The QUE_Get() and QUE_Put() only transfer a pointer to a message,
> rather than the actual message content.
>
> So I am wrong in the elimination of the freeQueue.
> Sorry about that.
> BTW:
> The code is also missing the following, probably just after the
> #include statements: void reader(void); // declaration for the reader task
> void writer(Int taskId); // declaration for the writer task
>
> The code is missing the following statements:
> extern SEM_Obj sem;
> extern QUE_Obj msgQueue;
> extern QUE_Obj freeQueue;
> extern LOG_Obj trace;
>
> And each of the writer_Msg variables that I wrote, need to be changed
> to a pointer, etc.
>
> If you want, I can send along a more realistic version.
>
> R. Williams
>
> ---------- Original Message -----------
> From: balasubramanian vaidhyanathan
> To: William C Bonner
> Cc: c...
> Sent: Wed, 24 Sep 2008 15:13:18 -0700 (PDT)
> Subject: [c6x] Issue understanding this code
>
> > Hi
> >
> > Below is the code I yanked out of TI BIOS User guide. Now what i
> > cant understand is this, the writer task has an id. In the document it
> > says there are three writers. So does that mean i have to create three
> > tasks and connect them to _writer and give same priority and run this
> > code so that i can have 3 writers?. I tried running with 2 writers and
> > the code does not behave as told. I ran with only one task and in the
> > reader() task i removed the 2 in the loop and the code exited
> > properly. Please explain.I have highlighted my confusing points in
> bold....
> >
> > regards
> > Bala
> >
> > #include
> > #include
> > #include
> > #include
> > #include
> > #include
> > #include "queuecfg.h"
> > #define NUMMSGS 3 /* number of messages */
> > #define NUMWRITERS 3
> > typedef struct MsgObj {
> > QUE_Elem elem; /* first field for QUE */
> > int id;
> > Char val; /* message value */
> > } MsgObj, *Msg;
> >
> > /*
> > * ======== main =======> > */
> > Void main()
> > {
> > int i;
> > MsgObj *msg;
> > Uns mask;
> > mask=TRC_LOGTSK|TRC_LOGSWI|TRC_STSSWI|TRC_LOGCLK;
> > TRC_enable(TRC_GBLHOST|TRC_GBLTARG|mask);
> > msg=(MsgObj *)MEM_alloc(0,NUMMSGS*sizeof(MsgObj),0);
> > if(msg==MEM_ILLEGAL)
> > {
> > SYS_abort("Memory allocation failed \n");
> > }
> > for(i=0;i > > {
> > QUE_put(&freeQueue,msg);
> > }
> > }
> > /* reader code */
> > void reader()
> > {
> > Msg msg;
> > Int i;
> > for(i=0;i > > {
> > SEM_pend(&sem,SYS_FOREVER);
> > msg=QUE_get(&msgQueue);
> > LOG_printf(&trace,"read '%c' from (%d)
> .",msg->val,msg->id);
> > QUE_put(&freeQueue,msg);
> > }
> > LOG_printf(&trace,"reader done\n");
> > }
> >
> > /* writer code */
> > void writer(Int id)
> > {
> > Msg msg;
> > Int i;
> >
> > for(i=0;i > > {
> > /* Get msg from the free queue*/
> > if(QUE_empty(&freeQueue))
> > {
> >
> > SYS_abort("Empty free queue\n");
> > }
> > msg=QUE_get(&freeQueue);
> > /*fill in value*/
> > msg->id=id;
> > msg->val=(i& 0xf)+'a';
> > LOG_printf(&trace,"(%d) writing
> '%c'...",id,msg->val);
> > QUE_put(&msgQueue,msg);
> > SEM_post(&sem);
> > }
> > LOG_printf(&trace,"Writer is done\n");
> > }
> >
> > --- On Wed, 9/24/08, William C Bonner wrote:
> >
> > From: William C Bonner
> > Subject: Re: [c6x] DSP/BIOS Task compile issue
> > To: "balasubramanian vaidhyanathan"
>
> > Cc: c...
> > Date: Wednesday, September 24, 2008, 11:04 AM
> >
> > When you couldn't get your project to compile, was it giving you
> > errors, or was it simply ignoring your code?
> >
> > I seem to remember something like this from when I was starting with
> > the TI compiler. I am pretty sure I set a flag to cause it to
> > recognize the .cpp extension as a c++ file. The extension used for
> > recognizing a C++ code file varied between compilers for a long time.
> > Many recognized .cc or .C while using .c for standard C code.
> >
> > balasubramanian vaidhyanathan wrote:
> > > I got my trial project to compile... Only because my file name was
> > > .cpp and i changed to .c it compiled.... i find this strange in
> > > DSP/BIOS... Has anyone faced this issue before?
> > >
> > >
> ------- End of Original Message -------
------- End of Original Message -------
Hi Richard

Are the three Ids three different tasks. I added three tasks in the cdb file and connected this function _write to the properties and executed the code still i get only one id.. Can you tell me how to get three id printed out?.....

--- On Wed, 9/24/08, Richard Williams wrote:

From: Richard Williams
Subject: Re: [c6x] Issue understanding this code
To: i...@yahoo.com, "William C Bonner"
Cc: c...
Date: Wednesday, September 24, 2008, 11:32 PM

balasub,,,
I ran the code, I now see why the 'freeQueue' was being initialized
with
pointer to messages/
I.E.
The QUE_Get() and QUE_Put() only transfer a pointer to a message, rather than
the actual message content.

So I am wrong in the elimination of the freeQueue.
Sorry about that.
BTW:
The code is also missing the following, probably just after the #include
statements:
void reader(void); // declaration for the reader task
void writer(Int taskId); // declaration for the writer task

The code is missing the following statements:
extern SEM_Obj sem;
extern QUE_Obj msgQueue;
extern QUE_Obj freeQueue;
extern LOG_Obj trace;

And each of the writer_Msg variables that I wrote, need to be changed to a
pointer, etc.

If you want, I can send along a more realistic version.

R. Williams

---------- Original Message -----------
From: balasubramanian vaidhyanathan
To: William C Bonner
Cc: c...
Sent: Wed, 24 Sep 2008 15:13:18 -0700 (PDT)
Subject: [c6x] Issue understanding this code

> Hi
>
> Below is the code I yanked out of TI BIOS User guide. Now what i
> cant understand is this, the writer task has an id. In the document it
> says there are three writers. So does that mean i have to create three
> tasks and connect them to _writer and give same priority and run this
> code so that i can have 3 writers?. I tried running with 2 writers and
> the code does not behave as told. I ran with only one task and in the
> reader() task i removed the 2 in the loop and the code exited
> properly. Please explain.I have highlighted my confusing points in
bold....
>
> regards
> Bala
>
> #include
> #include
> #include
> #include
> #include
> #include
> #include "queuecfg.h"
> #define NUMMSGS 3 /* number of messages */
> #define NUMWRITERS 3
> typedef struct MsgObj {
> QUE_Elem elem; /* first field for QUE */
> int id;
> Char val; /* message value */
> } MsgObj, *Msg;
>
> /*
> * ======== main ========
> */
> Void main()
> {
> int i;
> MsgObj *msg;
> Uns mask;
> mask=TRC_LOGTSK|TRC_LOGSWI|TRC_STSSWI|TRC_LOGCLK;
> TRC_enable(TRC_GBLHOST|TRC_GBLTARG|mask);
> msg=(MsgObj *)MEM_alloc(0,NUMMSGS*sizeof(MsgObj),0);
> if(msg==MEM_ILLEGAL)
> {
> SYS_abort("Memory allocation failed \n");
> }
> for(i=0;i > {
> QUE_put(&freeQueue,msg);
> }
> }
> /* reader code */
> void reader()
> {
> Msg msg;
> Int i;
> for(i=0;i > {
> SEM_pend(&sem,SYS_FOREVER);
> msg=QUE_get(&msgQueue);
> LOG_printf(&trace,"read '%c' from (%d)
.",msg->val,msg->id);
> QUE_put(&freeQueue,msg);
> }
> LOG_printf(&trace,"reader done\n");
> }
>
> /* writer code */
> void writer(Int id)
> {
> Msg msg;
> Int i;
>
> for(i=0;i > {
> /* Get msg from the free queue*/
> if(QUE_empty(&freeQueue))
> {
>
> SYS_abort("Empty free queue\n");
> }
> msg=QUE_get(&freeQueue);
> /*fill in value*/
> msg->id=id;
> msg->val=(i& 0xf)+'a';
> LOG_printf(&trace,"(%d) writing
'%c'...",id,msg->val);
> QUE_put(&msgQueue,msg);
> SEM_post(&sem);
> }
> LOG_printf(&trace,"Writer is done\n");
> }
>
> --- On Wed, 9/24/08, William C Bonner wrote:
>
> From: William C Bonner
> Subject: Re: [c6x] DSP/BIOS Task compile issue
> To: "balasubramanian vaidhyanathan"

> Cc: c...
> Date: Wednesday, September 24, 2008, 11:04 AM
>
> When you couldn't get your project to compile, was it giving you
> errors, or was it simply ignoring your code?
>
> I seem to remember something like this from when I was starting with
> the TI compiler. I am pretty sure I set a flag to cause it to
> recognize the .cpp extension as a c++ file. The extension used for
> recognizing a C++ code file varied between compilers for a long time.
> Many recognized .cc or .C while using .c for standard C code.
>
> balasubramanian vaidhyanathan wrote:
> > I got my trial project to compile... Only because my file name was
> > .cpp and i changed to .c it compiled.... i find this strange in
> > DSP/BIOS... Has anyone faced this issue before?
> >
> >
------- End of Original Message -------

Hi all My code is supposed to pend on a semaphore and i checked the semaphore count alsoit is zero. but the code still goes beyond SEM_pend when i step through. Why would it behave like this?. If the semaphorecount is zero then it should pend forever because ihave time out as SYS_FOREVER.... Have u faced this issue?>regardsBala