On Monday 30. March 2009 11.49.18 nidhi mittal wrote:
> i have a module of mine
>
> in which i have a data strcuture
> struct my_data{
> .
> .
> .
> .
>
> }
>
> struct my_data m1;
could you write a bit cleaner code, like
struct my_data {
int some_id;
};
static struct my_data m1;
>
> there is timer handling function
> handle_timer(data)
> {
>
>
>
> }
and (assuming you use hrtimers):
emum hrtimer_restart timer_handler(void *data)
{
/* timer code handling */
return HRTIMER_NORESTART;
}
static int __init init_module(void)
{
/* init handling, including timer*/
return 0;
}
> init_module
> {
> .
> .
> timer initialzed
>
> }
I'm not asking you to paste the entire code, but if you're adding code-
examples, make sure they actually make sense, and that they look somewhat
sensible. This is just gibberish and only adds noise to the email.
And, before I venture on to actually answer the question - could you please
write proper english? Not gramatically outstanding Queens-english, but at
least write complete sentences and words? Please, I beg you on my knees!
> suppose i want to access the my_data global data struct m1
> in handle_timer function .....
>
> then my ques is
>
> will i be able to access m1 in handle_timer directly thinking m1 a global
> variable
> i know it can be passed thru data arg but lets say i dont do that ...
Yes. But, and look at this but as a big, bold, fat *but* - make sure to handle
concurrent access. That will be the same for passing a pointer to a struct,
but in general, global variables and concurrency is not the best of friends.
> or
>
> it will nt be accessible there as handle timer when it will be executed
> ...it'll be in interrupt context
> at that time some other process might be in execution ...
> then these global var m1 wont be in its access ....
Your struct is statically allocated and given a static address - it doesn't
really matter from where in the kernel you call it, as long as the handler
knows the address, you can call it.
> pl clarify which of the two thoughts is correct .
First option :-)
<rant>
Give this some thought: how many seconds did you save by writing 'pl' instead
of 'please'? A full second? Half a second?
Then think about this: I had to read your email 3 times before I understood
all your questions, and even if I only had to read it twice, that took me an
extra 30 seconds. Now multiply that with all the people reading the list.
I know that I sound grumpy, perhaps I am, and I do not mean to scare you off,
on the contrary! I encourage you to continue learning and using Linux. I just
want you to understand that you will get a lot more constructive feedback if
you send off emails with a less 'sloppy' impression.
just my $0.02
</rant>
henrik
signature.asc
Description: This is a digitally signed message part.
