Version:
~ [ 0.6-2.3.46 ] ~
Architecture:
~ [ um ] ~
** Warning: Cannot open xref database.
1 #include "linux/sched.h"
2 #include "linux/threads.h"
3 #include "asm/smp.h"
4 #include "asm/processor.h"
5 #include "asm/spinlock.h"
6 #include "asm/softirq.h"
7 #include "asm/hardirq.h"
8 #include "user_util.h"
9 #include "kern_util.h"
10 #include "kern.h"
11
12 #ifdef __SMP__
13
14 /* Total count of live CPUs */
15 int smp_num_cpus = 0;
16
17 /* The 'big kernel lock' */
18 spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED;
19
20 /* Per CPU bogomips and other parameters */
21 struct cpuinfo_um cpu_data[NR_CPUS];
22
23 /* which CPU maps to which logical number */
24 int cpu_number_map[NR_CPUS];
25
26 spinlock_t um_bh_lock = SPIN_LOCK_UNLOCKED;
27
28 atomic_t global_bh_count;
29 atomic_t global_bh_lock;
30
31 unsigned char global_irq_holder = NO_PROC_ID;
32 unsigned volatile int global_irq_lock;
33
34 /* Set when the idlers are all forked */
35 int smp_threads_ready = 0;
36 int num_reschedules_sent = 0;
37
38 void smp_send_reschedule(int cpu)
39 {
40 num_reschedules_sent++;
41 }
42
43 static void show(char * str)
44 {
45 int cpu = smp_processor_id();
46
47 printk("\n%s, CPU %d:\n", str, cpu);
48 }
49
50 #define MAXCOUNT 100000000
51
52 static inline void wait_on_bh(void)
53 {
54 int count = MAXCOUNT;
55 do {
56 if (!--count) {
57 show("wait_on_bh");
58 count = ~0;
59 }
60 /* nothing .. wait for the other bh's to go away */
61 } while (atomic_read(&global_bh_count) != 0);
62 }
63
64 /*
65 * This is called when we want to synchronize with
66 * bottom half handlers. We need to wait until
67 * no other CPU is executing any bottom half handler.
68 *
69 * Don't wait if we're already running in an interrupt
70 * context or are inside a bh handler.
71 */
72 void synchronize_bh(void)
73 {
74 if (atomic_read(&global_bh_count) && !in_interrupt())
75 wait_on_bh();
76 }
77
78 void smp_send_stop(void)
79 {
80 printk("Stopping all CPUs\n");
81 }
82
83 void smp_commence(void)
84 {
85 }
86
87 void smp_boot_cpus(void)
88 {
89 if(ncpus < 1){
90 printk("ncpus set to 1\n");
91 ncpus = 1;
92 }
93 else if(ncpus > NR_CPUS){
94 printk("ncpus can't be greater than NR_CPUS, set to %d\n", NR_CPUS);
95 ncpus = NR_CPUS;
96 }
97 }
98
99 int setup_profiling_timer(unsigned int multiplier)
100 {
101 printk("setup_profiling_timer\n");
102 return(0);
103 }
104
105 #endif
106
107 int inited_cpus = 1;
108
109 int pid_to_processor_id(int pid)
110 {
111 int i;
112
113 for(i=0;i<inited_cpus;i++){
114 if(cpu_tasks[i].pid == pid) return(i);
115 }
116 panic("hard_smp_processor failed");
117 return(-1);
118 }
119
120 #ifdef __SMP__
121 int hard_smp_processor_id(void)
122 {
123 return(pid_to_processor_id(getpid()));
124 }
125 #endif
126
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.