From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,d7b3e296612ca5f8,start X-Google-Attributes: gidfee84,public From: Aurel Balmosan Subject: Is the usage of /usr/include/machine/builtins.h allowed for user processes? Date: 2000/01/05 Message-ID: <3873896C.74EDE248@orga.com>#1/1 X-Deja-AN: 568745601 X-Nntp-Posting-Host: 192.168.14.45 Content-Transfer-Encoding: 7bit Sender: news@orga.com (News Administrator) X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: ORGA Kartensysteme GmbH Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1 Hi, Recently I switch from SYSV ipcs semaphores over pthread mutex to spin locks. For that I use the function found in /usr/include/machine/builtins.h. I use two function of those: __RELEASE_SEM_LONG and __ACQUIRE_SEM_LONG_RETRY in the following context: static void _Lock(SHM_t *s, SHMlock_t *l) { struct timeval tv={0,1}; int loop=0; while (!__ACQUIRE_SEM_LONG_RETRY(&l->u.l.spin, 0)) { GenericCheck(s, loop++, l); select(0, NULL, NULL, NULL, &tv); } } static void _Unlock(SHM_t *s, SHMlock_t *l) { __RELEASE_SEM_LONG(&l->u.l.spin); } My questions are: 1. Will those function be supported also in 4.0f? (I check 4.0b 4.0d and 4.0e) 2. Do I need to align the integer spin specifically? I currently use an alignmend of 256 byte. 3. Am I allowed to use these buildins in the first place? 4. Currently I use a select() to force a context switch. Is there a better way to do it? 5. Could there be problems in very heavily loaded multi cpu systems? Well, from the general concept I don't see a problem since the spin's only lock functions with a max of 5000 cpu cycles while the outer functions have about 10 to 30 times more. Regards, Aurel Balmosan.