~ubuntu-branches/ubuntu/hardy/kvm/hardy-backports

« back to all changes in this revision

Viewing changes to user/test/smptest.c

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-11-15 02:21:55 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20071115022155-pxoxb8kfcrkn72mi
Tags: 1:52+dfsg-0ubuntu1
* New upstream release.
* 08_default_tdf.patch
  - Make -tdf the default and add a -no-tdf option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
#include "smp.h"
3
 
#include "printf.h"
4
 
 
5
 
static void ipi_test(void *data)
6
 
{
7
 
    int n = (long)data;
8
 
 
9
 
    printf("ipi called, cpu %d\n", n);
10
 
    if (n != smp_id())
11
 
        printf("but wrong cpu %d\n", smp_id());
12
 
}
13
 
 
14
 
static void smp_main(void)
15
 
{
16
 
    printf("smp main %d\n", smp_id());
17
 
    while (1)
18
 
        asm volatile ("hlt" : : : "memory");
19
 
}
20
 
 
21
 
int main()
22
 
{
23
 
    int ncpus;
24
 
    int i;
25
 
 
26
 
    smp_init(smp_main);
27
 
    ncpus = cpu_count();
28
 
    printf("found %d cpus\n", ncpus);
29
 
    for (i = 0; i < ncpus; ++i)
30
 
        on_cpu(i, ipi_test, (void *)(long)i);
31
 
    return 0;
32
 
}