Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 06 Oct 2001 15:22:42 +0900
From:      Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
To:        tlambert2@mindspring.com
Cc:        smp@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp
Subject:   Re: How to distinguish the SMP kernel and the UP kernel 
Message-ID:  <200110060622.PAA02409@zodiac.mech.utsunomiya-u.ac.jp>
In-Reply-To: Your message of "Fri, 05 Oct 2001 02:43:21 MST." <3BBD80B9.4191B288@mindspring.com> 
References:  <200110030310.MAA13836@zodiac.mech.utsunomiya-u.ac.jp> <3BBB6757.9A668E99@mindspring.com> <200110041211.VAA24646@zodiac.mech.utsunomiya-u.ac.jp>  <3BBD80B9.4191B288@mindspring.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
>> When hw.ncpu == 1, it doesn't necessarily signifies the kernel
>> is configured for UP. Because it is perfectly permissible
>> to run the SMP kernel on the multi-CPU motherboard with only one
>> CPU installed...
>> 
>> Am I wrong?
>
>No.
>
>I assumed you wanted the information to determine how many
>kernel threads, etc., to run in order to ensure that your
>code would operate optimally to take advantage of the extra
>hardware.  

No, you guessed wrong :-) I am not interested in
optimizing for the SMP environment.

I was simply interested in making a device driver into a module,
and found the following conditional in the code.

#ifdef SMP
	...
#else /* for UP */
	...
#endif

or

#ifdef APIC_IO
	...
#else
	...
#endif

In order to make this module work, we can do either

1) provide a kernel global variable to indicate whether
   the kernel is configured for SMP, or UP (smp_kernel), or

2) compile two versions of the module: one for SMP, another
   for UP, as you suggested. Load either of the two depending
   on the running kernel configuration.

If the code in question involves in manipulating structures which have
different members or sizes in SMP and UP kernels, the first approach
don't work, as you pointed out. 

The second approach won't work now, as neither the boot loader or
kldload has this capability at the moment.

Kazu





To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-smp" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200110060622.PAA02409>