English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 10 August 2023, 23:58   #1
hceline
Registered User
 
Join Date: Nov 2009
Location: Top of the world
Posts: 161
Question about P96 bitmap locking but mostly about timer.device

I'm trying to fix an old program that accesses graphics memory on RTG without taking any locks.
I've read the autodocs for both ChyberGraphics and Picasso96 and found lots of code examples.
But none of the examples I can find has any error-handling if they fail to acquire the lock.
Either they they just skip the whole operation on the bitmap, or they just do their thing anyway with cached pointers or other dubious tricks.
In the program in question I got a routine that can't do the former. It would make for a bad user experience as it's handling bitmap dragging with mouse.

I automatically went for a while-loop as in the following pseudo-code.
Code:
lock=LockBitmap()
while(not lock)
    {
    Delay(SomeTime)
    lock=LockBitmap()
    }
DoWork()
UnlockBitmap(lock)
But I lack the information needed to decide on the length of "SomeTime" and the choice of Delay()/TimeDelay() and eventually what timer.device UNIT to use in this case.
I do not want "SomeTime" to be unrealistically short, wasting cycles banging the lock to often. But I also want it short enough that the user-interface does not feel unnecessarily laggy if the lock fails.
If my window is open on "Workbench Screen" on a lightly loaded system and I'm maximally unlucky, trying the lock just as the OS/P96 has made a blocking lock, how long must I expect to wait? And what is the best delay-function/timer-source for this case? Anything else I'm missing?

-Hagbard Celine

Last edited by hceline; 11 August 2023 at 00:07.
hceline is offline  
Old 11 August 2023, 07:35   #2
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,247
Quote:
Originally Posted by hceline View Post
But none of the examples I can find has any error-handling if they fail to acquire the lock.
There is not really much to handle. If locking fails, then because the bitmap is not a P96 bitmap - the call itself blocks until the bitmap is available. Hence, error handling should just avoid drawing to anything because that "anything" passed in was nothing the function would be able to handle in first place and you cannot render on either.


Thus, a single "if" would be sufficient. If the lock is NULL, do not do anything.
Thomas Richter is offline  
Old 11 August 2023, 07:51   #3
hceline
Registered User
 
Join Date: Nov 2009
Location: Top of the world
Posts: 161
Ok, thank you.
hceline is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer.device memory leak? leemmcc Coders. C/C++ 6 01 February 2021 15:25
timer.device:GetSysTime:UNIT_VBLANK not recognized VladR Coders. Asm / Hardware 8 26 April 2020 12:44
Lamer question about scsi.device Jolabandola support.Apps 3 10 December 2019 20:00
[blitz] timer device + window IDCMP_INTUITICS = trouble peceha Coders. Blitz Basic 6 20 October 2019 22:02
Using timer.device in C (VBCC) DBAlex Coders. General 2 28 June 2011 22:10

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

Forum Jump


All times are GMT +2. The time now is 20:40.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.06971 seconds with 13 queries