Reputation: 986
I have 3 jobs (Job A, Job B and Job C). Job A Triggers Job C. I want the Job C to wait for the Job B to be completed and run the complete job.
Can we wait for a job to be completed?
I have read about polling. What does it do ? Can polling help me ?
Upvotes: 1
Views: 418
Reputation: 17574
I assume that by polling you mean "busy-waiting". This can help you, but it is generally regarded as an inefficient solution.
Well, imagine that you bought an item from Amazon or some other online shop. Polling is when you sit back home, and call Amazon every 5 seconds to know if your product has already arrived.
You can check a more formal definition on the wiki. To quote:
Polling is sometimes used synonymously with busy-wait polling. In this situation, when an I/O operation is required, the computer does nothing other than check the status of the I/O device until it is ready, at which point the device is accessed. In other words, the computer waits until the device is ready. Polling also refers to the situation where a device is repeatedly checked for readiness, and if it is not, the computer returns to a different task. Although not as wasteful of CPU cycles as busy waiting, this is generally not as efficient as the alternative to polling, interrupt-driven I/O.
So, polling as busy waiting means that you stay at home, waiting for the delivery guy and calling him every 5 seconds to check on his status. This is, a waste of your time if you have work or chores to do. You can alleviate this by calling the guy every 5 seconds, but instead of sitting and waiting to call him again, you can do some chores. This way you do some work, call the guy, and then get back. Every five seconds.
Although this alternative is better than true busy-waiting, it is still cumbersome to interrupt your activities every 5 seconds to check on the delivery guy.
The true alternative here is, as the wiki explains, interrupt-driven events. Continuing with my analogy, interrupt driven events mean that you buy something online, and then you go to work or you go to school or you do your chores. Because you have a cellphone, and the delivery guy also has one with your number, when he arrives, he calls you and you can come pick up your items.
The tricky part here is to make sure you code you cellphones correctly, meaning that you prepare the jobs A, B and C to be interrupted by events and respond accordingly. Depending on the case and on the tools you are using, it may not be trivial.
For a more specific answer, we need to know which technologies you are using and what kind of control you have over the jobs.
Well, here it is, I hope my analogies help you understand the concepts!
Upvotes: 1