Re: Reasons for a buffer or RAM
- From: Frank Kotler <fbkotler@xxxxxxxxxxx>
- Date: Wed, 01 Jun 2005 22:54:34 -0400
"Charles A. Crayne" wrote:
>
> On Wed, 01 Jun 2005 17:48:33 -0400
> Frank Kotler <fbkotler@xxxxxxxxxxx> wrote:
>
> :I want my buffer(s) on the stack, so it
> :can be recursive.
>
> You don't need to have your buffers on the stack to make it recursive. The
> better way is to allocate buffers dynamically and chain them together, as
> required.
Okay... I figured allocating buffers dynamically... keeping
a pointer on the stack... and freeing the buffer when I exit
the function (on each level) would be a way to do it. How
(and why) would I chain them together?
Seemed "simpler" to put 'em on the stack. Einstein said
(supposedly) that "things should be as simple as possible,
but no simpler." I may be trying to get "too simple" here...
> Of course, you may have to upgrade your antiquated kernel, if you can't get
> old mmap working.
Well, I think I can get old mmap working for "MAP_PRIVATE"
(which is what I'd want here, I think???). I was getting the
SIGBUS from trying to MAP_SHARED to communicate with a
process running in a different address space. It seems
(logically, and going by Randy's HLA example) that this
needs a file to "anchor" a shared memory area - without that
(or something) to "tie them together", how would the two
processes know it was the same area? Okay... but if this
file is zero-length, I get the SIGBUS by trying to write to
the area returned by mmap.
Randy's code apparently contains "O_TRUNC" (although it's
not "showing"... implied by "mmfile.openNew" I think) so I
always have a zero-length file, and it always fails. In my
Nasm code, I write one byte to the file before trying to
mmap it, and it works fine. I understand that mmap would
"round up" if I asked for one byte anyway, but I ask for
4096, and I can write to anywhere in that area - apparently
without actually writing anything to the disk file. SIGSEGV
if I try to write beyond it - SIGBUS seems limited to the
zero-length file in this case.
If this isn't limited to my kernel (2.2.19) - and maybe even
if it is - this might indicate a bug in Randy's hlalib code.
The "Linux end" of it hasn't been "exercised" as much as the
"Windows end", and it wouldn't be too astonishing to find a
bug lurking there.
I need to upgrade *anyway*, but I'd like to hear the results
of someone with a shiny new kernel trying Randy's code. The
Windows-specific "sleep" will have to be replaced (or just
commented out) for it to assemble. If it'll run without the
SIGBUS - even get as far as the "cls" - then it's a bug or
"version problem" here. If not, someone needs to look into
why not.
But thanks to T.M. Sommers' suggestion, *my* code works...
But that's a separate issue than why Jonathan suggested not
to make a .bss buffer over 16k...
Best,
Frank
.
- Follow-Ups:
- Re: Reasons for a buffer or RAM
- From: T.M. Sommers
- Re: Reasons for a buffer or RAM
- From: Charles A. Crayne
- Re: Reasons for a buffer or RAM
- References:
- Re: Reasons for a buffer or RAM
- From: Jonathan Bartlett
- Re: Reasons for a buffer or RAM
- From: Frank Kotler
- Re: Reasons for a buffer or RAM
- From: Charles A. Crayne
- Re: Reasons for a buffer or RAM
- Prev by Date: Re: Linux tools for M68000 programming
- Next by Date: Re: Reasons for a buffer or RAM
- Previous by thread: Re: Reasons for a buffer or RAM
- Next by thread: Re: Reasons for a buffer or RAM
- Index(es):
Relevant Pages
|
Loading