The millis() returns the number of milliseconds since the board has booted.
The millis() is defined in hardware/arduino/avr/cores/arduino/wiring.c as below. Only the souce code for Arduino UNO is quoted. The original source code supports many tips using #if’s.
The millis() has no input argument and returns unsigned long value.
First it reserves the status register SREG.
The SREG is a status register of ATMega328P.
Next it disables interrupt, copies the timer0_millis which holds the number of milliseconds to m, restores the reserved status register value and returns m. The timer0_millis is set in a interrupt handler named TIMER0_OVF_vect.
cli() is a macro that executes an assembler macro to disable interrupt.
As SREG includes interrupt flag, it is not need to enable interrupt explicitly.
June 19, 2020