• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

semaphores

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why do problems arise if two or more processes can access a semaphore concurrently?
 
Sheriff
Posts: 7135
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If such problems happens, that is not something where you should use semaphore on. If you need more helpful answer, can you elaborate your question a little more?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To elaborate some more, Java has a semaphore class -- the java.util.concurrent.Semaphore class -- and instances of it can't be accessed from outside the JVM. Actually, instances of any class can't be directly accessed outside of the JVM, and hence, can't be share between processes.

Henry
 
Devaka Cooray
Sheriff
Posts: 7135
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:... and hence, can't be share between processes.


Ah! I was misinterpreting that as sharing between threads. Sorry
 
Tumisang Montsho
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK guys! a bit of elaboration guys, one important application of semaphores is in the enforcement of mutual exclusion but processes using a semaphore must themselves access the semaphore under mutual exclusion. with reference to the operations on semaphores why might problems arise if two or more processes can access a semaphore concurrently.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tumisang Montsho wrote:OK guys! a bit of elaboration guys, one important application of semaphores is in the enforcement of mutual exclusion but processes using a semaphore must themselves access the semaphore under mutual exclusion. with reference to the operations on semaphores why might problems arise if two or more processes can access a semaphore concurrently.




You *really* need to get your terminology correct. Threads and processes are *not* the same thing. Also. I can't tell which semaphore you are referring to. We have been assuming that you are referring to the semaphore class in the java library (after all, this is a java site), but your other topic seems to imply that you are talking about about the UNIX IPC mechanism.

So, which is it? processes or threads? core library or UNIX IPC?

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic