Path: utzoo!attcan!uunet!lll-winken!ames!pasteur!ucbvax!decwrl!pyramid!oracle!hqpyr1!csimmons From: csimmons@hqpyr1.oracle.UUCP (Charles Simmons) Newsgroups: comp.arch Subject: MIPS Architechture Question Keywords: read-modify-write? What's that? Message-ID: <557@oracle.UUCP> Date: 13 Jan 89 04:03:13 GMT Sender: news@oracle.uucp Lines: 38 So, I'm sitting around one day porting some code to a MIPS R2000 processor, and suddenly I realize that I need a "test-and-set" instruction. Soon thereafter, I realize that the MIPS R2000 doesn't seem to have anything remotely resembling a read-modify-write instruction. (For my application, I can't inhibit interrupts, because I'm running in user mode.) So... a few questions arise. Some people around here find it hard to believe that a recently designed architechture doesn't have instructions for multiprocessor synchronization. Of course, these same people refuse to use any hardware that doesn't have at least 16 processors. For myself, I kind of started wondering what would happen if I started up a multiply instruction, and then did a load/nop/add/store squence of instructions while waiting for the multiply to complete. I looked into my reference manual (_MIPS R2000 RISC Architechture_ by Gerry Kane), and noticed that this small area wasn't talked about real well. So... What happens when the R2000 is executing a multiple cycle instruction (i.e. multiply or divide), and an interrupt, system call, or page fault occurs? Hmmm... I suppose the simplest implementation would be to do nothing special, and let the multiply or divide complete while the current context is being saved. Most likely, the multiply or divide will complete before getting around to saving HI and LO. So, I guess my questions are: 1) How much did the MIPS architechts worry about multiprocessor configurations, and why did they decide not to implement some sort of synchronization primitive? 2) Is there any real cute kludge anyone can suggest for faking something that would act like an interlocked instruction? Thanks, Chuck