Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > When an application crashes...

Reply
Thread Tools

When an application crashes...

 
 
Alexander Dong Back Kim
Guest
Posts: n/a
 
      04-11-2008
Hi all,

I'm working on a Linux machine and using g++. I'm developing an
semaphore module for a number of applications in the system.

My question scenario is, an application can lock a resource which is
shared memory segment in this case, after they locked a segment and if
they somehow crash then the lock won't be released because the
application locked the resource is dead.

I hope there must be a way to release the lock so solve this problem
even the application is crashed unexpectedly.

Any idea?

best regards,

Alex D. B. Kim
 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      04-11-2008
Alexander Dong Back Kim wrote:
> Hi all,
>
> I'm working on a Linux machine and using g++. I'm developing an
> semaphore module for a number of applications in the system.
>
> My question scenario is, an application can lock a resource which is
> shared memory segment in this case, after they locked a segment and if
> they somehow crash then the lock won't be released because the
> application locked the resource is dead.
>
> I hope there must be a way to release the lock so solve this problem
> even the application is crashed unexpectedly.
>


What is your C++ question? You're OT here. Ask in a Linux newsgroup.

1. If your question makes sense if you change the language, then it's
OT in comp.lang.c++.
2. If you question would not make sense if you change your platform
(i.e. linux=>windows), then it's OT in comp.lang.c++.
 
Reply With Quote
 
 
 
 
lbonafide@yahoo.com
Guest
Posts: n/a
 
      04-11-2008
On Apr 11, 10:42*am, Alexander Dong Back Kim <(E-Mail Removed)>
wrote:

>
> I hope there must be a way to release the lock so solve this problem
> even the application is crashed unexpectedly.


I think it would be better to find out why it's crashing and fix
that. If you post some code, maybe we can help.

 
Reply With Quote
 
peter koch
Guest
Posts: n/a
 
      04-11-2008
On 11 Apr., 17:42, Alexander Dong Back Kim <(E-Mail Removed)>
wrote:
> Hi all,
>
> I'm working on a Linux machine and using g++. I'm developing an
> semaphore module for a number of applications in the system.
>
> My question scenario is, an application can lock a resource which is
> shared memory segment in this case, after they locked a segment and if
> they somehow crash then the lock won't be released because the
> application locked the resource is dead.
>
> I hope there must be a way to release the lock so solve this problem
> even the application is crashed unexpectedly.
>
> Any idea?
>
> best regards,
>
> Alex D. B. Kim


This should be possible with some kind of heavyweight structure, but
the interesting question is why you would ever want to do that! If the
application crashes while it holds the semaphore, this datastructure
should by definition be defined as corrupted.
As to how to do it, I suggest a Linux group.

/Peter
 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      04-11-2008
peter koch wrote:
> On 11 Apr., 17:42, Alexander Dong Back Kim <(E-Mail Removed)>
> wrote:
>> Hi all,
>>
>> I'm working on a Linux machine and using g++. I'm developing an
>> semaphore module for a number of applications in the system.
>>
>> My question scenario is, an application can lock a resource which is
>> shared memory segment in this case, after they locked a segment and if
>> they somehow crash then the lock won't be released because the
>> application locked the resource is dead.
>>
>> I hope there must be a way to release the lock so solve this problem
>> even the application is crashed unexpectedly.
>>
>> Any idea?
>>
>> best regards,
>>
>> Alex D. B. Kim

>
> This should be possible with some kind of heavyweight structure, but
> the interesting question is why you would ever want to do that! If the
> application crashes while it holds the semaphore, this datastructure
> should by definition be defined as corrupted.
> As to how to do it, I suggest a Linux group.
>


He may be using SystemV IPC, which functions that way by design.
 
Reply With Quote
 
Alexander Dong Back Kim
Guest
Posts: n/a
 
      04-11-2008
On Apr 12, 2:15 am, red floyd <(E-Mail Removed)> wrote:
> Alexander Dong Back Kim wrote:
>
> > Hi all,

>
> > I'm working on a Linux machine and using g++. I'm developing an
> > semaphore module for a number of applications in the system.

>
> > My question scenario is, an application can lock a resource which is
> > shared memory segment in this case, after they locked a segment and if
> > they somehow crash then the lock won't be released because the
> > application locked the resource is dead.

>
> > I hope there must be a way to release the lock so solve this problem
> > even the application is crashed unexpectedly.

>
> What is your C++ question? You're OT here. Ask in a Linux newsgroup.
>
> 1. If your question makes sense if you change the language, then it's
> OT in comp.lang.c++.
> 2. If you question would not make sense if you change your platform
> (i.e. linux=>windows), then it's OT in comp.lang.c++.


so what? are you the manager of this group or what? If you don't know
the answer then just shut up.

 
Reply With Quote
 
Alexander Dong Back Kim
Guest
Posts: n/a
 
      04-11-2008
On Apr 12, 2:15 am, red floyd <(E-Mail Removed)> wrote:
> Alexander Dong Back Kim wrote:
>
> > Hi all,

>
> > I'm working on a Linux machine and using g++. I'm developing an
> > semaphore module for a number of applications in the system.

>
> > My question scenario is, an application can lock a resource which is
> > shared memory segment in this case, after they locked a segment and if
> > they somehow crash then the lock won't be released because the
> > application locked the resource is dead.

>
> > I hope there must be a way to release the lock so solve this problem
> > even the application is crashed unexpectedly.

>
> What is your C++ question? You're OT here. Ask in a Linux newsgroup.
>
> 1. If your question makes sense if you change the language, then it's
> OT in comp.lang.c++.
> 2. If you question would not make sense if you change your platform
> (i.e. linux=>windows), then it's OT in comp.lang.c++.


so what? are you the manager of this group or what? If you don't know
the answer then just shut up.

 
Reply With Quote
 
Alexander Dong Back Kim
Guest
Posts: n/a
 
      04-11-2008
On Apr 12, 3:31 am, peter koch <(E-Mail Removed)> wrote:
> On 11 Apr., 17:42, Alexander Dong Back Kim <(E-Mail Removed)>
> wrote:
>
>
>
> > Hi all,

>
> > I'm working on a Linux machine and using g++. I'm developing an
> > semaphore module for a number of applications in the system.

>
> > My question scenario is, an application can lock a resource which is
> > shared memory segment in this case, after they locked a segment and if
> > they somehow crash then the lock won't be released because the
> > application locked the resource is dead.

>
> > I hope there must be a way to release the lock so solve this problem
> > even the application is crashed unexpectedly.

>
> > Any idea?

>
> > best regards,

>
> > Alex D. B. Kim

>
> This should be possible with some kind of heavyweight structure, but
> the interesting question is why you would ever want to do that! If the
> application crashes while it holds the semaphore, this datastructure
> should by definition be defined as corrupted.
> As to how to do it, I suggest a Linux group.
>
> /Peter



Hi Peter,

The reason why I'm looking for this solution is, currently, I'm
developing an real time system using IPC. In the system, many
processes will run at the same time and they are independent from each
other. They also need to share their data so they are using shared
memory as a medium. However, since they can access and update the
shared memory simultaneously, I have been asked to implement a
implementation of a read/write lock for the multiple applications.
Therefore, I chose semaphore for this.

The problem of semaphore is, although they works beautifully, if a
process lock the semaphore and crashes immediately after the lock,
then the lock won't be unlocked. Therefore, there is no way other
applications can access the locked resource. Because of this reason, I
think I have to somehow protect unexpected terminations. In other
words, in order to unlock the resource before the process dies, I
think I have to catch some system message or destructor of the class.
I tried destructor way but it didn't call the destructor when the
application is unexpectedly killed.

Any suggestion for solving this problem?

Cheers,
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      04-11-2008
Alexander Dong Back Kim wrote:
> On Apr 12, 2:15 am, red floyd <(E-Mail Removed)> wrote:


>> Ask in a Linux newsgroup.

>
> so what? are you the manager of this group or what? If you don't know
> the answer then just shut up.
>

You where given the correct answer, see above. Your question was a
Linux/Unix one rather than a C++ language one.

--
Ian Collins.
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      04-11-2008
Alexander Dong Back Kim wrote:
>
> The problem of semaphore is, although they works beautifully, if a
> process lock the semaphore and crashes immediately after the lock,
> then the lock won't be unlocked. Therefore, there is no way other
> applications can access the locked resource. Because of this reason, I
> think I have to somehow protect unexpected terminations. In other
> words, in order to unlock the resource before the process dies, I
> think I have to catch some system message or destructor of the class.
> I tried destructor way but it didn't call the destructor when the
> application is unexpectedly killed.
>
> Any suggestion for solving this problem?
>

Yes, ask the experts on either a linux group or comp.unix.programmer.
There are a number of issues tied up on your question, some are system
specific (Sys V IPC) other more generic programming (how do you manage
possibly corrupt shared data if process crashes with a lock held).

Have fun.

--
Ian Collins.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Winform Application Configuration Deleted by Application lhak ASP .Net 0 10-23-2004 11:47 PM
Calling Windows application from Web application ASP .Net 1 11-02-2003 03:30 AM
What issue will HIT me hard when I convert an Access 2002 MDE application to Web Application? Sean ASP .Net 2 08-07-2003 07:13 AM
Application folder not seeing namespace of the main application gh0st54 ASP .Net 0 07-04-2003 07:15 PM
How to inherit a base form in all application forms of an asp.net application varun varun ASP .Net 0 07-03-2003 08:58 AM



Advertisments