From: David van Moolenbroek Date: Sun, 1 Aug 2010 22:07:46 +0000 (+0000) Subject: libdriver: allow driver to break out of message loop X-Git-Tag: v3.1.8~124 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/verify-sign/tz-link.htm?a=commitdiff_plain;h=20eced94e726a438fa69f52061303062a8407b69;p=minix.git libdriver: allow driver to break out of message loop --- diff --git a/include/minix/driver.h b/include/minix/driver.h index b5272b810..71b888a9c 100644 --- a/include/minix/driver.h +++ b/include/minix/driver.h @@ -67,6 +67,7 @@ _PROTOTYPE( void driver_announce, (void) ); _PROTOTYPE( int driver_receive, (endpoint_t src, message *m_ptr, int *status_ptr) ); _PROTOTYPE( int driver_receive_mq, (message *m_ptr, int *status_ptr) ); +_PROTOTYPE( void driver_terminate, (void) ); _PROTOTYPE( void driver_task, (struct driver *dr, int type) ); _PROTOTYPE( int driver_mq_queue, (message *m_ptr, int status) ); _PROTOTYPE( void driver_init_buffer, (void) ); diff --git a/lib/libdriver/driver.c b/lib/libdriver/driver.c index cb7655837..a6c3bfc8c 100644 --- a/lib/libdriver/driver.c +++ b/lib/libdriver/driver.c @@ -65,6 +65,7 @@ int device_caller; PRIVATE mq_t *queue_head = NULL; PRIVATE int open_devs[MAX_NR_OPEN_DEVICES]; PRIVATE int next_open_devs_slot = 0; +PRIVATE int driver_running; /*===========================================================================* * clear_open_devs * @@ -324,6 +325,17 @@ int *status_ptr; return driver_receive(ANY, m_ptr, status_ptr); } +/*===========================================================================* + * driver_terminate * + *===========================================================================*/ +PUBLIC void driver_terminate(void) +{ +/* Break out of the main driver loop after finishing the current request. + */ + + driver_running = FALSE; +} + /*===========================================================================* * driver_task * *===========================================================================*/ @@ -336,10 +348,12 @@ int type; /* Driver type (DRIVER_STD or DRIVER_ASYN) */ int r, proc_nr, ipc_status; message mess; + driver_running = TRUE; + /* Here is the main loop of the disk task. It waits for a message, carries * it out, and sends a reply. */ - while (TRUE) { + while (driver_running) { if ((r=driver_receive_mq(&mess, &ipc_status)) != OK) panic("driver_receive_mq failed: %d", r);