Linux-kernel mailing list archive 2000-29,: Re: C issues with spinlocks and preemption

# Re: C issues with spinlocks and preemption

ludovic fernandez (ludovic.fernandez@sun.com)
Tue, 18 Jul 2000 14:06:48 -0700

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Bill Huey: "Re: ext3-0.0.2e released"
- Previous message: Jan Harkes: "Re: [patch-2.4.0-test5-pre1] nullfs and forced umount"
- Maybe in reply to: George Anzinger: "C issues with spinlocks and preemption"
- Next in thread: George Anzinger: "Re: C issues with spinlocks and preemption"

Funny, I was doing the same thing....
I ran into the same problem and give up trying to make the
preemption functions inline.
The problem is that the structure task is not defined at the
point you declare your function. Defining them after the
declaration of task struct doesn't work either because some
header files need the spinlock definition very early (chicken and
eggs problem).

Note that I'm more or less done making the system preemptable
(I modified the interrupt path for i386 platform and the locking
stubs), but I also gave up trying to make it work on 2.4.XXX because
the SMP locking is not stable yet. Try to compile the kernel in UP with
the locking in debug mode and you'll see.

Ludo.

George Anzinger wrote:

> In the persuit of trying to use spinlocks macros for UP preemption I
> have come up with an interesting C problem and the way header files are
> being coded in the kernel. In particular:
>
> #include <linux/sched.h>
> #include <asm/current.h>
>
> static inline int foo(void)
> {
> int bar;
>
> bar = current->need_resched;
> return bar;
> }
>
> Works fine as a .c file, but if it is in a header file that is included
> by sched.h (such as tty.h) or indirectly included by sched.h (such as
> tqueue.h) cc complains about an incomplete type on the "current"
> reference.
>
> The problem is that sched.h, in such a case, actually has its body
> included after the above code and thus all cc has is a promise (i.e.
> struct task_struct;) and not the real task_struct. It appears that cc
> is compiling the "inline" function when it sees it, not when it is
> referenced.
>
> This is proving to be a tough nut to crack. Any thoughts?
>
> George
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.rutgers.edu
> Please read the FAQ at http://www.tux.org/lkml/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

- Next message: Bill Huey: "Re: ext3-0.0.2e released"
- Previous message: Jan Harkes: "Re: [patch-2.4.0-test5-pre1] nullfs and forced umount"
- Maybe in reply to: George Anzinger: "C issues with spinlocks and preemption"
- Next in thread: George Anzinger: "Re: C issues with spinlocks and preemption"