comp.lang.ada
 help / color / mirror / Atom feed
* pragma importing sem_init gives me a segmentation fault
@ 2007-02-24 20:52 laforge2001
  2007-02-25  0:01 ` Jeffrey Creem
  2007-02-25 15:32 ` Stephen Leake
  0 siblings, 2 replies; 6+ messages in thread
From: laforge2001 @ 2007-02-24 20:52 UTC (permalink / raw)


Hi,

I'm an ADA noob so please be gentle :) Anyways, I am trying to use
POSIX semaphores by pragma importing sem_init, sem_post, sem_wait,
etc. and it seems everytime I hit sem_init, the program seg faults.
Has anyone ever tried doing this before with any success ?

These semaphores are in shared memory and I believe I'm allocating the
same space in memory as a sem_t type. We are actually trying to
convert from an SGI platform to a Linux based platform, so all the
previous semaphore calls were SGI specific and we were looking to move
to POSIX based semaphores. Does anyone have any ideas how to go about
this ?

Thanks,
Eric




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pragma importing sem_init gives me a segmentation fault
  2007-02-24 20:52 pragma importing sem_init gives me a segmentation fault laforge2001
@ 2007-02-25  0:01 ` Jeffrey Creem
  2007-02-28 19:54   ` laforge2001
  2007-02-25 15:32 ` Stephen Leake
  1 sibling, 1 reply; 6+ messages in thread
From: Jeffrey Creem @ 2007-02-25  0:01 UTC (permalink / raw)


laforge2001@gmail.com wrote:
> Hi,
> 
> I'm an ADA noob so please be gentle :) Anyways, I am trying to use
> POSIX semaphores by pragma importing sem_init, sem_post, sem_wait,
> etc. and it seems everytime I hit sem_init, the program seg faults.
> Has anyone ever tried doing this before with any success ?
> 
> These semaphores are in shared memory and I believe I'm allocating the
> same space in memory as a sem_t type. We are actually trying to
> convert from an SGI platform to a Linux based platform, so all the
> previous semaphore calls were SGI specific and we were looking to move
> to POSIX based semaphores. Does anyone have any ideas how to go about
> this ?
> 
> Thanks,
> Eric
> 

POSIX.5 specifies a standard Ada binding to many of the services of POSIX.

IBM Ada Developer (formally Rational Apex) comes with a POSIX.5 interface.

There is a package available for GNAT called florist. You don't mention 
what compiler you are using but since you are coming from SGI it is 
probably a fairly safe bet that it is GNAT based.

In any case, florist does have an existing binding to sem_init so you 
can either look to it for guidance or actually consider using it.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pragma importing sem_init gives me a segmentation fault
  2007-02-24 20:52 pragma importing sem_init gives me a segmentation fault laforge2001
  2007-02-25  0:01 ` Jeffrey Creem
@ 2007-02-25 15:32 ` Stephen Leake
  2007-02-26  9:21   ` Maciej Sobczak
  1 sibling, 1 reply; 6+ messages in thread
From: Stephen Leake @ 2007-02-25 15:32 UTC (permalink / raw)


laforge2001@gmail.com writes:

> We are actually trying to convert from an SGI platform to a Linux
> based platform, so all the previous semaphore calls were SGI
> specific and we were looking to move to POSIX based semaphores. Does
> anyone have any ideas how to go about this ?

It might be better to redesign the program to use Ada protected types
rather than OS semaphores.

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pragma importing sem_init gives me a segmentation fault
  2007-02-25 15:32 ` Stephen Leake
@ 2007-02-26  9:21   ` Maciej Sobczak
  0 siblings, 0 replies; 6+ messages in thread
From: Maciej Sobczak @ 2007-02-26  9:21 UTC (permalink / raw)


Stephen Leake wrote:

> It might be better to redesign the program to use Ada protected types
> rather than OS semaphores.

If the semaphore is in shared memory (and it is, see original question), 
then I'd expect that some other programs make use of it. There is no 
provision that all such programs are written in Ada.

And how do you make a protected object that is shared between processes, 
btw?

-- 
Maciej Sobczak : http://www.msobczak.com/
Programming    : http://www.msobczak.com/prog/



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pragma importing sem_init gives me a segmentation fault
  2007-02-25  0:01 ` Jeffrey Creem
@ 2007-02-28 19:54   ` laforge2001
  2007-03-01  0:07     ` Jeffrey Creem
  0 siblings, 1 reply; 6+ messages in thread
From: laforge2001 @ 2007-02-28 19:54 UTC (permalink / raw)


On Feb 24, 4:01 pm, Jeffrey Creem <j...@thecreems.com> wrote:
> laforge2...@gmail.com wrote:
> > Hi,
>
> > I'm an ADA noob so please be gentle :) Anyways, I am trying to use
> > POSIX semaphores by pragma importing sem_init, sem_post, sem_wait,
> > etc. and it seems everytime I hit sem_init, the program seg faults.
> > Has anyone ever tried doing this before with any success ?
>
> > These semaphores are in shared memory and I believe I'm allocating the
> > same space in memory as a sem_t type. We are actually trying to
> > convert from an SGI platform to a Linux based platform, so all the
> > previous semaphore calls were SGI specific and we were looking to move
> > to POSIX based semaphores. Does anyone have any ideas how to go about
> > this ?
>
> > Thanks,
> > Eric
>
> POSIX.5 specifies a standard Ada binding to many of the services of POSIX.
>
> IBM Ada Developer (formally Rational Apex) comes with a POSIX.5 interface.
>
> There is a package available for GNAT called florist. You don't mention
> what compiler you are using but since you are coming from SGI it is
> probably a fairly safe bet that it is GNAT based.
>
> In any case, florist does have an existing binding to sem_init so you
> can either look to it for guidance or actually consider using it.


Hello,

Thanks for your response. It looks like FLORIST is exactly what I'm
looking for. Does anyone know if using the FLORIST library listed
here:

http://www.cs.fsu.edu/~baker/florist.html

Will work with GNAT version 3.4.6 ?

Thanks,
Eric




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pragma importing sem_init gives me a segmentation fault
  2007-02-28 19:54   ` laforge2001
@ 2007-03-01  0:07     ` Jeffrey Creem
  0 siblings, 0 replies; 6+ messages in thread
From: Jeffrey Creem @ 2007-03-01  0:07 UTC (permalink / raw)


laforge2001@gmail.com wrote:

> 
> Hello,
> 
> Thanks for your response. It looks like FLORIST is exactly what I'm
> looking for. Does anyone know if using the FLORIST library listed
> here:
> 
> http://www.cs.fsu.edu/~baker/florist.html
> 
> Will work with GNAT version 3.4.6 ?
> 
> Thanks,
> Eric
> 

Not sure. It might need a little patching. I assume you mean GCC 3.4.6 
not GNAT 3.4.6. In any case, do you really need to use that version?

gnuada.sf.net has some newer GCC versions available that work with newer 
versions of florist.

Is GNATPro an option?



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-03-01  0:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-24 20:52 pragma importing sem_init gives me a segmentation fault laforge2001
2007-02-25  0:01 ` Jeffrey Creem
2007-02-28 19:54   ` laforge2001
2007-03-01  0:07     ` Jeffrey Creem
2007-02-25 15:32 ` Stephen Leake
2007-02-26  9:21   ` Maciej Sobczak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox