LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-04-2007, 09:36 AM   #1
yantai
LQ Newbie
 
Registered: May 2007
Posts: 6

Rep: Reputation: 0
power failure interrupt


I am doing writing to a flash (NVM). This writing should be protected from power failure/system crash, which means that an "emergency rescue" function should be provided during the writing. Is it possible to implement this function through signal catch? and is "sigpwr" the right signal for power failure? Please advice ASAP.
 
Old 06-04-2007, 03:12 PM   #2
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,219

Rep: Reputation: 54
How would you write code to detect a power failure before it happens? I would get a battery back-up for protection at the hardware level. And if you're concerned about a system crash before the write is complete wait until it's finished before opening more programs.

It should also be mentioned that to further protect your flash storage device you should unmount it before any crash or outage occurs to further prevent data loss.
 
Old 06-05-2007, 07:01 AM   #3
yantai
LQ Newbie
 
Registered: May 2007
Posts: 6

Original Poster
Rep: Reputation: 0
write to flash during power down

Well, I really should say "power down" rather than "power failure"...my mistake.

Here is what I am doing -

To change the data stored in flash, it's first copied to ram buffer, after the data in the ram is changed, it copied back to flash.

HW/SW faults may cause system to power down. And it could happen when changing the data modified is still in ram buffer, or in the procedure writing back to the flash.
The code tries to save all those data in the ram buffer or carry on the writing back flash procedure even during powering down. I guess that powering down operation may force the operation on the files to stop. I would like this "force" operation wait until I finish the backup of the current RAM data or finish the write back flash operation.

How the codes to communicate with powering down event? Is there any API available that I can send message to the system to demand "powering down pending" and then after susccesful write to flash I can send "power down is OK" to the system?

Last edited by yantai; 06-05-2007 at 07:03 AM.
 
Old 06-05-2007, 07:59 AM   #4
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,219

Rep: Reputation: 54
You haven't specified what distro you're using, but with Slackware I've never had that be a problem. If there's a write to flash pending when I tell it to shutdown it completes the write during shutdown - unless it's a hard crash instead of a "power down". If you're afraid of a hardware or software event causing shutdown wait for the write to finish before doing anything that might cause such an event. And try not to use ndiswrapper for wifi since it can be unpredictable.

Oh, to avoid losing the data this is what I do and what I suggest to everyone I meet - keep backups. Copy to a place on the hard disk first, then from there to flash.
 
Old 06-06-2007, 04:40 AM   #5
yantai
LQ Newbie
 
Registered: May 2007
Posts: 6

Original Poster
Rep: Reputation: 0
It is not a slackware distro. I downloaded linux kernel 2.6.16.11 from linux kernel website. And other packages (such as busybox, mplayer etc.) from different websites.

The powerdown is not supposed to be a normal powerdown. Rather it is casued by HW/SW faults. And I am not supposed to know what exact HW/SW events they are. What I need is to be aware that the system is "powering down" and started write whatever changes in the buffer to flash. I don't know how to catch "powering down" event though, would it be possible from power management? And what power management package provides such a API so that the user can catch "powering down" message and then send "pending" message back?

The system is "diskless" - there is no hard disk available
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
set iBook to automatically power-up after power failure peachy Other *NIX 4 04-19-2006 01:44 PM
Power Failure On AC power ONLY Gateway 5300 marti35 Linux - Laptop and Netbook 1 05-22-2005 11:14 AM
Workstation power failure etcetera Linux - Hardware 7 12-17-2004 10:05 AM
help!, power failure, fsck lin00b Linux - Newbie 3 08-19-2004 06:48 AM
Crash after power failure deesto *BSD 8 07-29-2003 02:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration