Gopinath
Gopinath

Reputation: 241

local_irq_save(flags), How does this API stores state of interrupt system?

As per LKD 3rd edition, local_irq_save(flags) API saves the state of interrupt system and restores it back with local_irq_restore(flags).

1) What does state of interrupt system means?

2) As the value is passed by value, how does the local variable stores any content?

Upvotes: 0

Views: 831

Answers (1)

user4822941
user4822941

Reputation:

1) Well, enabled or disabled. I'm pretty sure it is explained in the book.

2) have you tried looking at the code?

#define raw_local_irq_restore(flags)                    \
        do {                                            \
                typecheck(unsigned long, flags);        \
                arch_local_irq_restore(flags);          \
        } while (0)
#define raw_local_save_flags(flags)                     \
        do {                                            \
                typecheck(unsigned long, flags);        \
                flags = arch_local_save_flags();        \
        } while (0)

these are not functions, but just macros. easy to verify their behaviour in a hand-rolled c program in userspace. arguably it's a crap style to have a macro modify a var and not "take" an address.

Upvotes: 2

Related Questions