41 lines · 493 B · C
RawDownload
#include <u.h>#include <libc.h> voidlock(Lock *lk){	int i; 	/* once fast */	if(!_tas(&lk->val))		return;	/* a thousand times pretty fast */	for(i=0; i<1000; i++){		if(!_tas(&lk->val))			return;		sleep(0);	}	/* now nice and slow */	for(i=0; i<1000; i++){		if(!_tas(&lk->val))			return;		sleep(100);	}	/* take your time */	while(_tas(&lk->val))		sleep(1000);} intcanlock(Lock *lk){	if(_tas(&lk->val))		return 0;	return 1;} voidunlock(Lock *lk){	lk->val = 0;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t