Computer Hope

Software => Computer programming => Topic started by: UglyPepper on December 01, 2020, 04:09:27 AM

Title: How does a computer “wait” time?
Post by: UglyPepper on December 01, 2020, 04:09:27 AM
Me and a friend were discussing how programming languages can perform asynchronous tasks, like waiting 15 seconds before performing another task, and we started a debate.

I know that computers have an internal clock that uses the CMOS battery that can keep track of time, but how does it know it has been 15 seconds since right now and since when I told it to wait 15 seconds without looping infinitely and performing conditional operations, or does it do that?
Title: Re: How does a computer “wait” time?
Post by: Lisa_maree on December 01, 2020, 03:35:15 PM
Me and a friend were discussing how programming languages can perform asynchronous tasks, like waiting 15 seconds before performing another task, and we started a debate.

I know that computers have an internal clock that uses the CMOS battery that can keep track of time, but how does it know it has been 15 seconds since right now and since when I told it to wait 15 seconds without looping infinitely and performing conditional operations, or does it do that?

The CMOS data is used only when the computer starts to get the current date and time after which the OS updates the date and time. If software needs an interval timed it uses timer interrupts.

Here is a better explanation than I can do   https://www.visualmicro.com/page/Timer-Interrupts-Explained.aspx
Title: Re: How does a computer “wait” time?
Post by: UglyPepper on December 02, 2020, 03:28:56 AM
The CMOS data is used only when the computer starts to get the current date and time after which the OS updates the date and time. If software needs an interval timed it uses timer interrupts.

Here is a better explanation than I can do   https://www.visualmicro.com/page/Timer-Interrupts-Explained.aspx/MyGroundBiz (https://www.mygroundbiz.online/)

I got sufficient information from your soul of heart.Thank you so much