Skip to content
Advertisement

Tag: operating-system

Implement the `sleep()` and `awake()` in java

I need to develop the sleep() and awake() functions of the OS. I have runningJobs queue, and sleepingJobs queue. The sleep method should receive a Job and insert it in the sleeping queue in the right place, and the awake() method should move the sleeping jobs that are ready to run, to the runningJobs queue. In not sure how to

Mutex Locks vs Peterson’s Algorithm?

Do mutex locks ensure bounded waiting condition ? Is it possible if two threads are trying to get hold of a lock, but only one process (just by luck) gets it again and again. Since Peterson’s Algorithm ensures bounded waiting, is it better to use that instead of mutex locks ? Answer It is possible to have unbounded wait with

System stack allocation in recursion

As we all know that all most all recursive functions can be modified to iterative approach. Suppose we take an example of adding two linklists which represent two huge numbers. This question can be solved either by recursion (which uses system stack) or iterative (explicit stack usage) approach. My doubt here is if i have given jvm heap size as

Does any JVM implement blocking with spin-waiting?

In Java Concurrency in Practice, the authors write: When locking is contended, the losing thread(s) must block. The JVM can implement blocking either via spin-waiting (repeatedly trying to acquire the lock until it succeeds) or by suspending the blocked thread through the operating system. Which is more efficient depends on the relationship between context switch overhead and the time until

Advertisement