English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 29 March 2011, 20:05   #1
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,767
Question about the TAS instruction.

Hi,

The 680x0 guide file I have, says this about the TAS instruction:

Quote:
This instruction uses read-modify-write cycle, which is not dividable and allows synchronisation of several processors. But this instruction is NOT ALLOWED ON AMIGA!
I've tried this instruction, but nothing out of the ordinary seems to happen Is this statement correct, or is TAS safe to use?

Any pointers are appreciated
Thorham is offline  
Old 29 March 2011, 20:18   #2
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,004
TAS isn't safe to use on Zorro II systems, as certain conditions are expected and never happen.

TAS is also not a good idea on Amiga as the instruction can cause a bus lock during an interrupt, with that certain part of memory thats been Tested and Set, is now not available to other processors, which will cause problems.

From what I can remember, a TAS will cause a bus lock at any time, not at the end of of a interrupt cycle.
Galahad/FLT is offline  
Old 29 March 2011, 20:32   #3
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,519
It isn't safe.

One issue is TAS to chip RAM + Agnus DMA accesses at the same time = incorrectly working TAS.

Problem is TAS's special cycle (read-modify-write cycle which is unsupported on Amiga) When TAS read cycle has finished, it can't be stopped anymore, write cycle will start and in worst case Agnus is also using this cycle for DMA (because it thought TAS read cycle was normal single read cycle)

I haven't seen any bus lockups, only wrong TAS results (but I have only been testing it on chip RAM)
Toni Wilen is offline  
Old 29 March 2011, 20:51   #4
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,767
Thanks guys

Pity, but luckily there's still BSET, so no problem. As long as testing and setting can't be interrupted, I'm happy
Thorham is offline  
Old 31 March 2011, 18:06   #5
hitchhikr
Registered User
 
Join Date: Jun 2008
Location: somewhere else
Posts: 515
Does this rule apply to a "tas dx" like form ?
I seems to remember that what it does just set the bit 7 of the specified data register.
hitchhikr is offline  
Old 31 March 2011, 20:43   #6
Kalms
Registered User
 
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 237
What is the purpose of the atomicity?

There is no atomic read+write operation against memory in the Amigas. (Unless CAS/CAS2 are supported, which I don't think they are.) So there is no way to perform an atomic read-modify-write operation, which is guaranteed not to be intercepted by another DMA capable device in the system.

However if you seek atomicity with regards to interrupts within the same CPU, the situation is easier; the CPU will only check for external interrupts between the processing of two instructions. So, if you know that the instruction itself will not generate an exception (perhaps because you're attempting to read/write a page which has been marked as unavailable by the MMU) then you can implement semi-atomic operations by using ordinary logic operations where you can deduce the old value from the new. For instance a semaphore:

Code:
acquireSemaphore:
		addq.b	#1,semaphore			; attempt to acquire semaphore
		beq.s	.done				; if current value = 0, you acquired it
		subq.b	#1,semaphore
		; wait for some time (or for an event) before re-trying
		bra.s	acquireSemaphore

.done:		rts

releaseSemaphore:
		subq.b	#1,semaphore
		rts

semaphore:	dc.b	255
But again - the question is, what is the purpose of the atomicity?
Kalms is offline  
Old 31 March 2011, 21:18   #7
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,767
Quote:
Originally Posted by Kalms View Post
What is the purpose of the atomicity?
I need this for insuring that a task exception won't do certain things, such as killing the task, while the task is inside a critical section. I wanted to use TAS for this, but BSET works as well, because I don't need the read-write cycle, I just need a test and a write to be done in one go (using two instructions means the exception can happen after the test, and before the write and this is bad in my code).

Last edited by Thorham; 31 March 2011 at 21:24.
Thorham is offline  
Old 03 April 2011, 13:12   #8
Wepl
Moderator
 
Wepl's Avatar
 
Join Date: Nov 2001
Location: Germany
Posts: 866
the question arises if tas/cas would be save on real fast mem? but afaik there can be dma too (for example scsi/ata/ethernet)
Wepl 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
MUI Programming Instruction offered AmigaDave Coders. General 2 03 May 2013 23:34
Optimizing question: instruction order TheDarkCoder Coders. Asm / Hardware 9 29 October 2011 17:07
Instruction cache question Lord Riton Coders. General 2 07 April 2011 12:25
Please help me: one by one instruction needed JewStrangler support.WinUAE 15 20 September 2010 18:55
$48e70000 instruction Asman Coders. General 5 10 February 2006 23:00

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 04:30.

Top

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