Commit b2711b96 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: change semaphores to completions

From: Esben Nielsen <simlo at phys au dk>

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.
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 660f6e31
......@@ -25,7 +25,7 @@ struct port_list {
struct list_head list;
atomic_t wait_count;
int has_connection;
struct semaphore sem;
struct completion done;
int port;
int fd;
spinlock_t lock;
......@@ -68,7 +68,7 @@ static irqreturn_t pipe_interrupt(int irq, void *data, struct pt_regs *regs)
conn->fd = fd;
list_add(&conn->list, &conn->port->connections);
up(&conn->port->sem);
complete(&conn->port->done);
return(IRQ_HANDLED);
}
......@@ -197,13 +197,12 @@ void *port_data(int port_num)
{ .list = LIST_HEAD_INIT(port->list),
.wait_count = ATOMIC_INIT(0),
.has_connection = 0,
.sem = __SEMAPHORE_INITIALIZER(port->sem,
0),
.port = port_num,
.fd = fd,
.pending = LIST_HEAD_INIT(port->pending),
.connections = LIST_HEAD_INIT(port->connections) });
spin_lock_init(&port->lock);
init_completion(&port->done);
list_add(&port->list, &ports);
found:
......@@ -237,7 +236,7 @@ int port_wait(void *data)
atomic_inc(&port->wait_count);
while(1){
fd = -ERESTARTSYS;
if(down_interruptible(&port->sem))
if(wait_for_completion_interruptible(&port->done))
goto out;
spin_lock(&port->lock);
......@@ -308,14 +307,3 @@ static void free_port(void)
}
__uml_exitcall(free_port);
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
......@@ -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 @@ static irqreturn_t xterm_interrupt(int irq, void *data, struct pt_regs *regs)
return(IRQ_NONE);
xterm->new_fd = fd;
up(&xterm->sem);
complete(&xterm->ready);
return(IRQ_HANDLED);
}
......@@ -49,10 +49,10 @@ int xterm_fd(int socket, int *pid_out)
/* 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 @@ int xterm_fd(int socket, int *pid_out)
*
* 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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment