| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Semaphore |
DN> blocked on the resource RC> and how many will be blocked on other things. In one of my RC> programs which typically has about 10 threads I use critical RC> sections because I believe that it would waste CPU time if all RC> threads used semaphores when accessing certain data structures. All RC> I have to do is to use DosEnterCritSect() whenever I'm doing RC> something that requires exclusive access to the data and I don't RC> need to worry about semaphores in the other threads. DN> The overheads of calling DosEnterCritSec() and DosExitCritSec() will DN> be slightly higher than DosRequestMutexSem() and DosReleaseMutexSem() DN> because of all the dispatcher checking involved to determine currently DN> ready threads. A mutex is a simple lock word with a queue. That may be true IF I was to use the same number of system calls. DN> Since you need to make one API call prior to using a resource and DN> another after you're done with it, you end up making the same number DN> of API calls, but you've chosen the more expensive API. Your active DN> thread will be slower than if you used mutexes and it will block other DN> threads unnecessarily. Yes. However when using semaphores you have to request them before using the resource and release them afterwards. If a resource is being read much more often than it's being written then the use of critical sections in the code to write to the resource can dramatically decrease the number of system calls. If the program performs 1/10th the number of system calls and each system call takes twice as long then it will perform those operations 5 times faster. Russell Coker --- Maximus/2 2.02* Origin: Multi - 61-3-9739-7145 - multi.apana.org.au (3:633/363) SEEN-BY: 50/99 620/243 625/100 632/107 348 360 633/154 260 362 363 371 373 SEEN-BY: 633/374 634/396 397 635/301 502 503 544 639/252 711/409 410 413 430 SEEN-BY: 711/808 809 934 955 712/515 713/888 800/1 @PATH: 633/363 260 371 635/503 50/99 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.