All of lore.kernel.org
 help / color / mirror / Atom feed
From: "michele.paolino" <michele.paolino@studio.unibo.it>
To: Xen-devel@lists.xensource.com,
	George Dunlap <george.dunlap@eu.citrix.com>
Subject: Re: generate random numbers
Date: Thu, 25 Feb 2010 19:31:17 +0100	[thread overview]
Message-ID: <14f366f91002251031g538dcffan9fe5208b5d981444@mail.gmail.com> (raw)
In-Reply-To: <1266016370.15135.2942.camel@agari.van.xensource.com>


[-- Attachment #1.1: Type: text/plain, Size: 359 bytes --]

Here's my random scheduler. It works until I start a virtual machine (error
file attached is the serial console's log).
In xen call trace there isn't any of my functions.
To generate random numbers I'm using the hash (MD5) of NOW() function.
I would also Know why at boot time there are two calls at vcpu_init function
for vcpu with id = 0 ??

Thanks
Michele

[-- Attachment #1.2: Type: text/html, Size: 410 bytes --]

[-- Attachment #2: error --]
[-- Type: application/octet-stream, Size: 1992 bytes --]

(XEN) ----[ Xen-3.4.2  x86_32p  debug=n  Not tainted ]----
(XEN) CPU:    0
(XEN) EIP:    e008:[<ff1380ff>] write_cr3+0x2f/0x50
(XEN) EFLAGS: 00000046   CONTEXT: hypervisor
(XEN) eax: 0000e39c   ebx: 0000e39c   ecx: 0000e39c   edx: 00000000
(XEN) esi: 00000096   edi: 00000000   ebp: ffbe6000   esp: ff227eb4
(XEN) cr0: 8005003b   cr4: 000006f0   cr3: 325a5000   cr2: 08492c54
(XEN) ds: e010   es: e010   fs: 0000   gs: 0000   ss: e010   cs: e008
(XEN) Xen stack trace from esp=ff227eb4:
(XEN)    00000000 00000000 ffbe8000 ff135f1b 00000000 ff204220 00000000 00000000
(XEN)    ff274000 ff101000 ffbe6384 ff204100 ff204100 129e2718 ffbe6000 00000000
(XEN)    ff227fb4 ffbe6000 ff274000 ff1371d1 ffbe6024 135d0eb8 00000016 0042297c
(XEN)    ff204100 ff204100 00000000 ffbe6000 129e2718 00000000 ff274000 ff116b4d
(XEN)    ff274000 ffbe6000 00000016 134f7b4e ff274000 ff116565 ff204024 ff204090
(XEN)    00989680 00000000 134f7b4e 00000016 ff204080 00000002 ff204024 c03e9e2c
(XEN)    00000020 0000007b ff227fb4 ffbe6000 00989680 00000000 0000007b 00000000
(XEN)    ff227fb4 0000007b c041c180 ff117b45 00000000 ff274000 0000007b ff1b63a6
(XEN)    00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)    00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(XEN)    00000000 00000000 ffbe6000
(XEN) Xen call trace:
(XEN)    [<ff1380ff>] write_cr3+0x2f/0x50
(XEN)    [<ff135f1b>] __context_switch+0x18b/0x270
(XEN)    [<ff101000>] boot_cpu_gdt_table+0x0/0x1000
(XEN)    [<ff1371d1>] context_switch+0xa1/0x190
(XEN)    [<ff116b4d>] schedule+0x1bd/0x410
(XEN)    [<ff116565>] do_sched_op+0x95/0x4c0
(XEN)    [<ff117b45>] do_softirq+0x35/0x70
(XEN)    [<ff1b63a6>] process_softirqs+0x6/0x10
(XEN)    
(XEN) 
(XEN) ****************************************
(XEN) Panic on CPU 0:
(XEN) GENERAL PROTECTION FAULT
(XEN) [error_code=0000]
(XEN) ****************************************
(XEN) 
(XEN) Reboot in five seconds...

[-- Attachment #3: sched_random.c --]
[-- Type: text/x-csrc, Size: 2620 bytes --]

#include <xen/lib.h>
#include <xen/sched.h>
#include <xen/time.h>
#include <xen/sched-if.h>
#include <xen/softirq.h>
#include <xen/errno.h>
#include <xen/list.h>
#include <xen/timer.h>
#include <xen/randmd5.h>

int tot_vcpu=0;
MD5_CTX mdContext;

struct random_vcpu_info{
    struct list_head lista;
    struct vcpu *vcpu;
}*runnable;


void __init_runnable(void){
    runnable=xmalloc(struct random_vcpu_info);
    INIT_LIST_HEAD(&runnable->lista);
    printk("\nINIT runnable list\n");
}


static int random_vcpu_init(struct vcpu *v){
    struct random_vcpu_info *inf;
    inf= xmalloc(struct random_vcpu_info);
    if ( inf == NULL ) return -1;

    INIT_LIST_HEAD(&inf->lista);

    inf->vcpu=v;
    runnable->vcpu=v; 
    list_add(&inf->lista,&runnable->lista);
    tot_vcpu++; 
    printk("\n\nadd VCPU %d\n\n", v->vcpu_id);
    return 0;    
}

//destroy vcpu


struct task_slice random_schedule(s_time_t now){
    struct task_slice ret;
    struct random_vcpu_info *inf;
    int next_vcpu;

    printk("\n\nscheduling..\n");
    
    //MD5Final returns a random integer
    next_vcpu = (MD5Final (&mdContext)) % tot_vcpu;
    printk("\n\n\nnext_vcpu = %d",next_vcpu);
    inf = runnable;
    
    while (next_vcpu!=0){
        inf = list_entry(&runnable->lista, struct random_vcpu_info, lista );
        printk("runnable->v =%d", runnable->vcpu->vcpu_id);
        list_move_tail(&runnable->lista, &runnable->lista);
        next_vcpu--;
        printk("\nshifting list\n");   
    }
    ret.task= inf->vcpu;
    ret.time = MILLISECS(10);
    printk("\n\nI'm scheduling.. vcpi_id=%d , tot_vcpu=%d",inf->vcpu->vcpu_id,tot_vcpu);
    return ret;
}


static void __random_init(void){
    unsigned char digest[16];
    int i;
    long unsigned int mask= 0xFF;
    long unsigned int string_now = NOW();
    MD5Init (&mdContext);

    for (i=0;i<8;i++){
        digest[i]=(char) ((string_now & mask) >> 8*i);
        mask <<=8;
    }

    printk("Init Random Number Generator with word %x", (unsigned int) digest);
    MD5Update (&mdContext, (unsigned char*)prova, sizeof(s_time_t));
    printk("\n\nUpdating Random Generator\n");

}

static void random_vcpu_wake( struct vcpu *vc){
    printk("\n\nwake up!!!!!!!!!!!!\n\n");
    cpu_raise_softirq(smp_processor_id(),SCHEDULE_SOFTIRQ);
    __random_init();
    return;
}



struct scheduler sched_random_def = {
    .name           = "my Random Scheduler",
    .opt_name       = "random",
    .sched_id       = 17,
    .init_vcpu      = random_vcpu_init,
    .wake           = random_vcpu_wake,
    .destroy_vcpu   = NULL,
    .do_schedule    = random_schedule,

};




[-- Attachment #4: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  reply	other threads:[~2010-02-25 18:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-11 20:31 generate random numbers michele.paolino
2010-02-12  1:51 ` James Harper
2010-02-12  8:32   ` michele.paolino
2010-02-12 12:15     ` George Dunlap
2010-02-12 22:42       ` michele.paolino
2010-02-12 23:12         ` Daniel Stodden
2010-02-25 18:31           ` michele.paolino [this message]
2010-02-25 21:25             ` George Dunlap
2010-02-26 17:43               ` michele.paolino
2010-02-26 17:44                 ` George Dunlap
2010-02-26 18:54                   ` michele.paolino
2010-03-01 11:41                     ` George Dunlap
2010-03-01 16:56                       ` michele.paolino
2010-03-02 12:58                         ` George Dunlap
2010-03-03  7:52                           ` michele.paolino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14f366f91002251031g538dcffan9fe5208b5d981444@mail.gmail.com \
    --to=michele.paolino@studio.unibo.it \
    --cc=Xen-devel@lists.xensource.com \
    --cc=george.dunlap@eu.citrix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.