User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Java: writing a .img file to disk in linux Page [1]  
LittleZZ
Veteran
442 Posts
user info
edit post

I am working on a program and part of it involves writing a .img file to a floppy. Currently I am implementing this by a Runtime Process that executes dd in Linux. This works fine except that I want to notify the user when the process is finished and if there were any errors. All of this wouldn't be a problem if i could simply use Process.waidfor(), but I am running it from a SWT GUI, and when the waitfor() is called, it interupts the GUI refresh and all of the widgits disapear. When the process is done, they come back, but I'm trying to get it where it doesn't look like there are any problems and the widgets stay on the screen.

I have tried running the process in a new thread, seperate from my GUI, and that works, but if I don't synchronize the threads, there is a delay (about a minute) between when the disk write is finished, and when the user feed back is displayed on the screen. This brings about another problem in that if I synchronize the threads, I have to make the GUI thread wait for the notification from the disk write thread, and this creates the same issue as using .waitfor().

So, I'm wondering if anyone can help by knowing:

1) if there is another way to see if a process is finished executing besides using waitfor(). If i can set up a loop I can run the refresh code and it shouldn't be a problem.

or

2) if there is a Java API for writing an image to a disk so I don't have to use dd and a separate process. This would probably be best (and would allow me to write the images to disk without rawwrite in windows), although my knowledge of what to do to get it all working would be in the area of retarded.

Thanks

1/24/2006 3:33:24 PM

Shaggy
All American
17820 Posts
user info
edit post

a real ghetto way to do it would be to parse the output stream for specific strings


i know theses a better way b/c i did something similar

ill look at my code when i get home

1/24/2006 5:04:09 PM

LittleZZ
Veteran
442 Posts
user info
edit post

thanks Shaggy...I've actually gotten it working.

With SWT you have to use Display.asyncExec() to run a thread without fucking everything up. I could have sworn I had tried it before and it didn't work, but for some reason it worked after I posted. I guess its one of those, as soon as you try to show someone else it starts working kinds of things. That said, if you could double check what you've done in the past that would be helpful so I can do the same thing with Windows and Linux. Right now I have to run rawwrite sepparately for Windows, and I'd like to be able to control everything from one program as it is supposed to be an all inclusive application for some stuff here at work. Thanks again for your help

1/24/2006 6:13:05 PM

Shaggy
All American
17820 Posts
user info
edit post

hah

looking back now i synchronized the threads

and

Quote :
"a real ghetto way to do it would be to parse the output stream for specific strings "


is exactly how i did it.

I had a runtime process running in the background with a thread listening to its output stream for updates.

When updates happened the thread releases its lock on an object in the GUI and the GUI changes based on this.

Its definately not the cleanest method and in some cases the lock on the object freezes the GUI. I could probably do a better job of handling the synchonized stuff, but Display Async is probably easier and the correct way to do it.

1/24/2006 8:56:39 PM

 Message Boards » Tech Talk » Java: writing a .img file to disk in linux Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.