Kashev Georgi wrote: > In a project, that I work on, I need to sort datas in > a database record. The sorting must be as quick as > possible, but the record is large (~10KB). There is > not enought dinamic memory for a temporary buffer, so > sorting must be made directly in storage heap. The use > of DmWrite makes the process too slow. I have tried to > disable the protection, but failed. It seems I have no > access to Hardware maped registers. I have searched > the documentations of MC68000 and DragonBall series, > but did not find a way to switch processor in > supervisor mode.
Under PalmOS, the Dragonball CPU is (almost) always working in supervisor mode. But that shouldn't motivate you to access the hw registers (Don't try to change the tyre while the car is moving...) Your question is one of those which are usually subject to "you can't do that" replies because the correct answer would contain the magic words "system use only". If someone would give you a technically (not politically) correct answer, he would talk about semaphores and reserving/releasing them..., however, no one would do so, and thus you cannot use these 'forbidden' functions because the risk of using them without knowing their internals would be too high. However, 10k shouldn't be worth the risk of plowing through the storage heap. Are you really sure you can't effort that space on the heap? If not, here are two spontaneous ideas: I. Depending on the size of the data chunks you are keeping in your record, there could be a solution if you keep in mind that readonly access to the storage heap is done directly: - Allocate an array of pointers (*p[]) and set each pointer to the beginning of a data section in the record. - Let your sorting algorithm rearrange the array such that p[0] points to the first data section in sorting order, p[1] to the 2nd etc. - Copy as many data sections as your dynamic memory allows you to, following the order of the array on the heap. - If there's no more heap space available, append the data to a new record using DmWrite(). - Repeat the last step until you've copied all data. That way you could minimize the number of DmWrite calls. Note that this approach makes sense only if you're dealing with data sections much larger than 4 bytes ;-). II. How about increasing the stack size of your application and doing the work on the stack? That's a dirty thing and I don't know whether this makes sense for 10k, but it's possible indeed. Cheers, Bernd Abel <http://www.berndabel.de> -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
