Skip to contentSkip to conversation

Global variables

DISCUSSION roni 3 participants 4 messages Jun 14, 2015

lore
Share & tools
lore

roni

author
#0 lore raw

I know i should avoid using global variables in kernel programming.

What problem it create if i use more global variables?

#1 lore raw
Quoted 11 lines · roni

I know i should avoid using global variables in kernel programming.

What problem it create if i use more global variables?

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

you step on everyone else's names space. Do you know how many other people are collaborating with the kernel. Stick to your own back yard.

#2 lore raw
Quoted 14 lines · Ruben Safir
Quoted 11 lines · roni

I know i should avoid using global variables in kernel programming.

What problem it create if i use more global variables?

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Quoted 7 lines

you step on everyone else's names space. Do you know how many other people are collaborating with the kernel. Stick to your own back yard.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Besides, it hampers reentrancy, unless you use locks(mutex) with each global variable.
Kernel functions can be called by different processes in parallel and they might also be
called/scheduled from interrupt context.

#3 lore raw
Quoted 2 lines · AYAN KUMAR HALDER

Besides, it hampers reentrancy, unless you use locks(mutex) with each global variable.

This is not necessary a function of globalization of variables, although it damn sure can be, but... honestly, if he is asking this question, it is not likely that he yet understands race conditions and critical areas.