Re: Real-Time Preemption and UML?

Esben Nielsen
2005-02-07T23:14:45Z

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1276 bytes --]

Well, I keep trying a little bit more. In the mean while you can get some
of the stuff I needed to change to at least get it to compile:

One of the problems was use of direct architecture specific semaphores
(which doesn't work under PREEMPT_REALTIME) and in places where a quick
(maybe too quick) look at the code told me that completions ought to be
used. Therefore I changed two semaphores to completions which compiled
fine. I have tried the change on 2.6.11-rc2, and it seemed to work, but I
have not tested it heavily.

The patch is in an attachment - I hope the mail-list will alow that. It is
simply too trouplesome otherwise when I am using Pine as mail client.

Esben

On Mon, 7 Feb 2005, Jeff Dike wrote:

> simlo@phys.au.dk said:
> > Hi, I am trying to compile and run UM-Linux with PREEMPT_REALTIME. I
> > managed to get it to compile but it wont start - it simply stops
> > somewhere in start_kernel() :-(
>
> I've never played with preemption on UML. No doubt it needs some work...
>
> Jeff
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

[-- Attachment #2: Type: TEXT/PLAIN, Size: 2383 bytes --]

--- linux-2.6.11-rc2-um/arch/um/drivers/port_kern.c.orig 2005-01-23 15:53:29.000000000 +0100
+++ linux-2.6.11-rc2-um/arch/um/drivers/port_kern.c 2005-02-06 19:54:52.000000000 +0100
@@ -23,7 +23,7 @@
struct port_list {
struct list_head list;
int has_connection;
- struct semaphore sem;
+ struct completion done;
int port;
int fd;
spinlock_t lock;
@@ -66,7 +66,7 @@
conn->fd = fd;
list_add(&conn->list, &conn->port->connections);

- up(&conn->port->sem);
+ complete(&conn->port->done);
return(IRQ_HANDLED);
}

@@ -183,13 +183,14 @@
*port = ((struct port_list)
{ .list = LIST_HEAD_INIT(port->list),
.has_connection = 0,
- .sem = __SEMAPHORE_INITIALIZER(port->sem,
- 0),
.lock = SPIN_LOCK_UNLOCKED,
.port = port_num,
.fd = fd,
.pending = LIST_HEAD_INIT(port->pending),
.connections = LIST_HEAD_INIT(port->connections) });
+
+ init_completion(&port->done),
+
list_add(&port->list, &ports);

found:
@@ -221,7 +222,7 @@
int fd;

while(1){
- if(down_interruptible(&port->sem))
+ if(wait_for_completion_interruptible(&port->done))
return(-ERESTARTSYS);

spin_lock(&port->lock);
--- linux-2.6.11-rc2-um/arch/um/drivers/xterm_kern.c.orig 2005-01-23 15:53:29.000000000 +0100
+++ linux-2.6.11-rc2-um/arch/um/drivers/xterm_kern.c 2005-02-06 19:54:58.000000000 +0100
@@ -16,7 +16,7 @@
#include "xterm.h"

struct xterm_wait {
- struct semaphore sem;
+ struct completion ready;
int fd;
int pid;
int new_fd;
@@ -32,7 +32,7 @@
return(IRQ_NONE);

xterm->new_fd = fd;
- up(&xterm->sem);
+ complete(&xterm->ready);
return(IRQ_HANDLED);
}

@@ -49,10 +49,10 @@

/* This is a locked semaphore... */
*data = ((struct xterm_wait)
- { .sem = __SEMAPHORE_INITIALIZER(data->sem, 0),
- .fd = socket,
+ { .fd = socket,
.pid = -1,
.new_fd = -1 });
+ init_completion(&data->ready);

err = um_request_irq(XTERM_IRQ, socket, IRQ_READ, xterm_interrupt,
SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
@@ -68,7 +68,7 @@
*
* XXX Note, if the xterm doesn't work for some reason (eg. DISPLAY
* isn't set) this will hang... */
- down(&data->sem);
+ wait_for_completion(&data->ready);

free_irq_by_irq_and_dev(XTERM_IRQ, data);
free_irq(XTERM_IRQ, data);