Intro Download and install Frequently Asked Questions Tips and tricks

Homepage







© J.C. Kessels 2009
MyDefrag Forum
May 24, 2013, 06:13:23 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Diagonal Lines  (Read 5284 times)
isgdre
JkDefrag Hero
*****
Posts: 71


View Profile
« on: December 12, 2008, 07:38:07 pm »

Hi, I hear to have a solution to the diagonal lines problem for 4.0.

Having looked into it a while back.  I'd be interested in knowing what the problem was. 
Any hints? :-)
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7155



View Profile WWW
« Reply #1 on: December 13, 2008, 10:22:32 am »

The problem is that JkDefrag is multithreading, and Windows is not. JkDefrag v3 makes changes to the window from 2 threads, and Windows cannot handle that. Version 4 uses the "PostMessage" system call from the defragmentation thread to send drawing instructions to the graphics thread, which then executes them. It makes the display a lot slower, but has solved the problem.
Logged
isgdre
JkDefrag Hero
*****
Posts: 71


View Profile
« Reply #2 on: December 15, 2008, 04:39:58 pm »

Under the Food for thought category.  I have come across this as well but since I was working on a communications program simply living with the slow down wasn't an option.
So I created a circular buffer (head/tail type) created some command codes (like draw line, update header) and had the worker thread write to it at full speed.  Then the GUI thread would read the buffer and update the screen when it had time.

I also used a 'sloppy update' so I didn't need semaphores and such that meant my messages had a 0-1.5 second delay to getting the screen but none of the users every new that.

I have also used in the past something where I would group up a few updates in the worker thread and then post the entire group using the "PostMessage".  But that method could make things look a bit choppy.

Another method I have used (and this one maybe over kill for your app) is to create to separate programs.  A JKDeFragGUI and JKDefragCMD, where JKDefragCMD would be a command line version of the program that is capable of running without a window.  JKDefragGUI would fork off JKDefragCMD and chat to it via Sockets.   This method is the one that I use most currently.  It has lots of advantages but it does have a few downsides.  May not be good if you have LOTS of things to say and though communications logs make debugging between the apps a breeze, debugging the background task can be a little more challenging. 

Anyway, I'm sure your working on much more important parts of V4.0 so performance may not be a big issue for the first kick at the re-write cat.  Also, once V4.0 is up and running you may find that 98% of it's time is in the actual file moves so making the last 2% (the gui updates) twice as fast may not be of any real benifet.

So, like I said.  Food for thought.
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7155



View Profile WWW
« Reply #3 on: December 16, 2008, 08:41:30 am »

Thanks for sharing your thoughts, I appreciate it. Version 3 wrote directly to the screen, nice and fast. Version 4 has a lot more overhead because of having to post messages, and the graphics are now using far more than 2% of the time. A full screen redraw every second is now faster (in some cases) than immediate screen updates.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!