Ask a Question related to Mac Programming, Design and Development.
-
vvvv #1
ringbuffers on os9
this is part of a program i am writing to receive data at interrupt time and
put it into a ringbuffer. i am crashing! can somebody point out my mistake?
does it have to do with Handles?
here is my ringbuffer:
typedef struct RINGBUFFER_Tag{
Handle buff;
unsigned long buffSize;
unsigned long buffCount;
int wError;
MYTHING* buffStart;
MYTHING* buffEnd;
MYTHING* buffHead;
MYTHING* buffTail;
} RINGBUFFER;
on program start, i call MakeBuffer(500):
long MakeBuffer(int size){
inbuffer = new RINGBUFFER;
inbuffer->buff = NewHandle(size * sizeof(MYTHING));
HLock(inbuffer->buff);
inbuffer->buffCount = 0L;
inbuffer->buffSize = size;
inbuffer->buffStart = (MYTHING *)inbuffer->buff;
inbuffer->buffEnd = (MYTHING *)inbuffer->buff + inbuffer->buffSize;
inbuffer->buffTail =(MYTHING *)inbuffer->buff;
inbuffer->buffHead = (MYTHING *)inbuffer->buff;
// i was DebugStr-ing here to see if there was MemErr(), and wasn't
getting any errors
// is there a better way of testing here than that?
return 0;
}
at interrupt time, i receive: MYTHING* pkt in a callback.
i process pkt like this at interrupt time in my callback proc:
MYTHING incoming = (MYTHING)*pkt;
(MYTHING)*inbuffer->buffHead = incoming;// i tried casting about 10 diff
ways, no luck
++inbuffer->buffHead;
++inbuffer->buffCount;
if(inbuffer->buffHead >=inbuffer->buffEnd)
inbuffer->buffHead = inbuffer->buffStart;
I crash at this point. help!
vvvv
vvvv Guest
-
Sean McBride #2
Re: ringbuffers on os9
In article <2vg3b.61699$Sq.10740812@twister.nyc.rr.com>,
"vvvv" <noone@nowhere.com> wrote:
<http://developer.apple.com/documentation/mac/Memory/Memory-62.html>> this is part of a program i am writing to receive data at interrupt time and
> put it into a ringbuffer. i am crashing! can somebody point out my mistake?
> does it have to do with Handles?
says:
"Note that Memory Manager routines like HLock return their results via
MemError and therefore should not be called in interrupt code."
You have to be realy careful what you call at interrupt time.
Sean McBride Guest
-
vvvv #3
Re: ringbuffers on os9
i redid my ringbuffer to have NewPtr instead of newhandle, and all the
problems went away.
which begs the question...why?
memory is NOT easy!
vvvv
"Manfred Lippert" <mani@mani.de> wrote in message
news:BB7504AD.192B4%mani@mani.de...>> > Handle buff;
> > [...]
> > MYTHING* buffStart;
> > [...]
> > inbuffer->buffStart = (MYTHING *)inbuffer->buff;
> A Mac Handle is a "pointer to a pointer", so I think you have to write the
> following here (and on some other places):
>
> inbuffer->buffStart = (MYTHING *)*(inbuffer->buff);
>
> Bye,
> Mani
>
vvvv Guest
-
Dmitry Markman #4
Re: ringbuffers on os9
On 8/30/03 1:01, in article BB75A803.6CDE%dimamarkman@attbi.com, "Dmitry
Markman" <dimamarkman@attbi.com> wrote:
sorry should be> typedef *Ptr Handle
typedef Ptr * Handle;
Dmitry Markman
Dmitry Markman Guest
-
Frederick Cheung #5
Re: ringbuffers on os9
On Sat, 30 Aug 2003, vvvv wrote:
Because a pointer is not the same thing as a handle.> i redid my ringbuffer to have NewPtr instead of newhandle, and all the
> problems went away.
>
> which begs the question...why?
Fred
Frederick Cheung Guest



Reply With Quote

