| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Semaphore |
DT> EnterCritSec is OK if your app does not have many threads (2-3 max). DT>If you have more than that, then you should use semaphores (local). DT>Critcal sections will stop ALL other threads in your process from DT>running, when most times all you need is to protect a single resource. It really depends on how many threads will be blocked on the resource and how many will be blocked on other things. In one of my programs which typically has about 10 threads I use critical sections because I believe that it would waste CPU time if all threads used semaphores when accessing certain data structures. All I have to do is to use DosEnterCritSect() whenever I'm doing something that requires exclusive access to the data and I don't need to worry about semaphores in the other threads. One thing that makes it easy for me to do this is that all the threads are blocked on IO for >99.9% of the time, this means that it's quite acceptable for a thread to lock all the other threads out for a few milliseconds as they are probably blocked anyway. A system call takes more CPU time than 1000 user-mode instructions. The fewer OS calls you make the faster your program will run and the lower the pulse rating will be. cya ___ X MR/2 2.0 NR X This message transmitted on 100% recycled photons. --- 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 635/301 502 503 506 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™.