=== modified file 'kernel/generic/include/ipc/ipc.h'
--- kernel/generic/include/ipc/ipc.h	2010-12-14 17:00:02 +0000
+++ kernel/generic/include/ipc/ipc.h	2011-01-01 19:34:52 +0000
@@ -43,7 +43,7 @@
 #define IPC_CALL_LEN  6
 
 /** Maximum active async calls per phone */
-#define IPC_MAX_ASYNC_CALLS  4
+#define IPC_MAX_ASYNC_CALLS 	10 
 
 /* Flags for calls */
 

=== modified file 'kernel/generic/src/ipc/ipc.c'
--- kernel/generic/src/ipc/ipc.c	2010-12-14 17:00:02 +0000
+++ kernel/generic/src/ipc/ipc.c	2011-01-01 20:25:13 +0000
@@ -705,8 +705,9 @@
 				printf("connecting ");
 				break;
 			case IPC_PHONE_CONNECTED:
-				printf("connected to: %p ",
-				    task->phones[i].callee);
+				printf("connected to: %p (%" PRIu64 ") ",
+				    task->phones[i].callee,
+				    task->phones[i].callee->task->taskid);
 				break;
 			case IPC_PHONE_SLAMMED:
 				printf("slammed by: %p ", 

=== modified file 'uspace/lib/c/generic/io/vprintf.c'
--- uspace/lib/c/generic/io/vprintf.c	2010-04-20 15:01:43 +0000
+++ uspace/lib/c/generic/io/vprintf.c	2011-01-08 20:52:48 +0000
@@ -36,11 +36,11 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <io/printf_core.h>
-#include <futex.h>
+#include <fibril_synch.h>
 #include <async.h>
 #include <str.h>
 
-static atomic_t printf_futex = FUTEX_INITIALIZER;
+static FIBRIL_MUTEX_INITIALIZE(printf_mutex);
 
 static int vprintf_str_write(const char *str, size_t size, void *stream)
 {
@@ -84,18 +84,11 @@
 	/*
 	 * Prevent other threads to execute printf_core()
 	 */
-	futex_down(&printf_futex);
-	
-	/*
-	 * Prevent other fibrils of the same thread
-	 * to execute printf_core()
-	 */
-	async_serialize_start();
+	fibril_mutex_lock(&printf_mutex);
 	
 	int ret = printf_core(fmt, &ps, ap);
 	
-	async_serialize_end();
-	futex_up(&printf_futex);
+	fibril_mutex_unlock(&printf_mutex);
 	
 	return ret;
 }

=== modified file 'uspace/lib/c/generic/loader.c'
--- uspace/lib/c/generic/loader.c	2010-12-14 12:52:38 +0000
+++ uspace/lib/c/generic/loader.c	2011-01-08 20:55:28 +0000
@@ -62,7 +62,7 @@
 
 loader_t *loader_connect(void)
 {
-	int phone_id = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_LOAD, 0, 0);
+	int phone_id = async_connect_me_to_blocking(PHONE_NS, SERVICE_LOAD, 0, 0);
 	if (phone_id < 0)
 		return NULL;
 	

=== modified file 'uspace/lib/c/generic/vfs/vfs.c'
--- uspace/lib/c/generic/vfs/vfs.c	2010-12-14 12:52:38 +0000
+++ uspace/lib/c/generic/vfs/vfs.c	2010-12-30 16:47:24 +0000
@@ -45,37 +45,48 @@
 #include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <async.h>
-#include <atomic.h>
-#include <futex.h>
+#include <fibril_synch.h>
 #include <errno.h>
 #include <str.h>
 #include <devmap.h>
 #include <ipc/vfs.h>
 #include <ipc/devmap.h>
+#include <assert.h>
 
 static int vfs_phone = -1;
-static futex_t vfs_phone_futex = FUTEX_INITIALIZER;
-static futex_t cwd_futex = FUTEX_INITIALIZER;
+static FIBRIL_MUTEX_INITIALIZE(vfs_phone_mutex);
+static FIBRIL_MUTEX_INITIALIZE(cwd_mutex);
 
 static int cwd_fd = -1;
 static char *cwd_path = NULL;
 static size_t cwd_size = 0;
 
+static void vfs_serialize_start(void)
+{
+	fibril_mutex_lock(&vfs_phone_mutex);
+}
+
+static void vfs_serialize_end(void)
+{
+	assert(fibril_mutex_is_locked(&vfs_phone_mutex));
+	fibril_mutex_unlock(&vfs_phone_mutex);
+}
+
 char *absolutize(const char *path, size_t *retlen)
 {
 	char *ncwd_path;
 	char *ncwd_path_nc;
 
-	futex_down(&cwd_futex);
+	fibril_mutex_lock(&cwd_mutex);
 	size_t size = str_size(path);
 	if (*path != '/') {
 		if (!cwd_path) {
-			futex_up(&cwd_futex);
+			fibril_mutex_unlock(&cwd_mutex);
 			return NULL;
 		}
 		ncwd_path_nc = malloc(cwd_size + 1 + size + 1);
 		if (!ncwd_path_nc) {
-			futex_up(&cwd_futex);
+			fibril_mutex_unlock(&cwd_mutex);
 			return NULL;
 		}
 		str_cpy(ncwd_path_nc, cwd_size + 1 + size + 1, cwd_path);
@@ -84,7 +95,7 @@
 	} else {
 		ncwd_path_nc = malloc(size + 1);
 		if (!ncwd_path_nc) {
-			futex_up(&cwd_futex);
+			fibril_mutex_unlock(&cwd_mutex);
 			return NULL;
 		}
 		ncwd_path_nc[0] = '\0';
@@ -92,7 +103,7 @@
 	str_append(ncwd_path_nc, cwd_size + 1 + size + 1, path);
 	ncwd_path = canonify(ncwd_path_nc, retlen);
 	if (!ncwd_path) {
-		futex_up(&cwd_futex);
+		fibril_mutex_unlock(&cwd_mutex);
 		free(ncwd_path_nc);
 		return NULL;
 	}
@@ -104,15 +115,16 @@
 	ncwd_path = str_dup(ncwd_path);
 	free(ncwd_path_nc);
 	if (!ncwd_path) {
-		futex_up(&cwd_futex);
+		fibril_mutex_unlock(&cwd_mutex);
 		return NULL;
 	}
-	futex_up(&cwd_futex);
+	fibril_mutex_unlock(&cwd_mutex);
 	return ncwd_path;
 }
 
 static void vfs_connect(void)
 {
+	assert(fibril_mutex_is_locked(&vfs_phone_mutex));
 	while (vfs_phone < 0)
 		vfs_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 0, 0);
 }
@@ -153,8 +165,7 @@
 		return ENOMEM;
 	}
 	
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	sysarg_t rc_orig;
@@ -162,8 +173,7 @@
 	sysarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size);
 	if (rc != EOK) {
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		free(mpa);
 		
 		if (null_id != -1)
@@ -178,8 +188,7 @@
 	rc = async_data_write_start(vfs_phone, (void *) opts, str_size(opts));
 	if (rc != EOK) {
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		free(mpa);
 		
 		if (null_id != -1)
@@ -194,8 +203,7 @@
 	rc = async_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name));
 	if (rc != EOK) {
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		free(mpa);
 		
 		if (null_id != -1)
@@ -211,8 +219,7 @@
 	rc = async_req_0_0(vfs_phone, IPC_M_PING);
 	if (rc != EOK) {
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		free(mpa);
 		
 		if (null_id != -1)
@@ -225,8 +232,7 @@
 	}
 	
 	async_wait_for(req, &rc);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	free(mpa);
 	
 	if ((rc != EOK) && (null_id != -1))
@@ -247,16 +253,14 @@
 	if (!mpa)
 		return ENOMEM;
 	
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	req = async_send_0(vfs_phone, VFS_IN_UNMOUNT, NULL);
 	rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size);
 	if (rc != EOK) {
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		free(mpa);
 		if (rc_orig == EOK)
 			return (int) rc;
@@ -266,8 +270,7 @@
 	
 
 	async_wait_for(req, &rc);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	free(mpa);
 	
 	return (int) rc;
@@ -275,8 +278,7 @@
 
 static int open_internal(const char *abs, size_t abs_size, int lflag, int oflag)
 {
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	ipc_call_t answer;
@@ -287,8 +289,7 @@
 		sysarg_t rc_orig;
 		async_wait_for(req, &rc_orig);
 		
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		
 		if (rc_orig == EOK)
 			return (int) rc;
@@ -297,8 +298,7 @@
 	}
 	
 	async_wait_for(req, &rc);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	
 	if (rc != EOK)
 	    return (int) rc;
@@ -321,8 +321,7 @@
 
 int open_node(fdi_node_t *node, int oflag)
 {
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	ipc_call_t answer;
@@ -331,8 +330,7 @@
 	
 	sysarg_t rc;
 	async_wait_for(req, &rc);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	
 	if (rc != EOK)
 		return (int) rc;
@@ -344,14 +342,12 @@
 {
 	sysarg_t rc;
 	
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	rc = async_req_1_0(vfs_phone, VFS_IN_CLOSE, fildes);
 	
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	
 	return (int)rc;
 }
@@ -362,8 +358,7 @@
 	ipc_call_t answer;
 	aid_t req;
 
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	req = async_send_1(vfs_phone, VFS_IN_READ, fildes, &answer);
@@ -372,16 +367,14 @@
 		sysarg_t rc_orig;
 	
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		if (rc_orig == EOK)
 			return (ssize_t) rc;
 		else
 			return (ssize_t) rc_orig;
 	}
 	async_wait_for(req, &rc);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	if (rc == EOK)
 		return (ssize_t) IPC_GET_ARG1(answer);
 	else
@@ -394,8 +387,7 @@
 	ipc_call_t answer;
 	aid_t req;
 
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	req = async_send_1(vfs_phone, VFS_IN_WRITE, fildes, &answer);
@@ -404,16 +396,14 @@
 		sysarg_t rc_orig;
 	
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		if (rc_orig == EOK)
 			return (ssize_t) rc;
 		else
 			return (ssize_t) rc_orig;
 	}
 	async_wait_for(req, &rc);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	if (rc == EOK)
 		return (ssize_t) IPC_GET_ARG1(answer);
 	else
@@ -422,22 +412,19 @@
 
 int fsync(int fildes)
 {
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	sysarg_t rc = async_req_1_0(vfs_phone, VFS_IN_SYNC, fildes);
 	
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	
 	return (int) rc;
 }
 
 off64_t lseek(int fildes, off64_t offset, int whence)
 {
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	sysarg_t newoff_lo;
@@ -446,8 +433,7 @@
 	    LOWER32(offset), UPPER32(offset), whence,
 	    &newoff_lo, &newoff_hi);
 	
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	
 	if (rc != EOK)
 		return (off64_t) -1;
@@ -459,14 +445,12 @@
 {
 	sysarg_t rc;
 	
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	rc = async_req_3_0(vfs_phone, VFS_IN_TRUNCATE, fildes,
 	    LOWER32(length), UPPER32(length));
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	
 	return (int) rc;
 }
@@ -476,8 +460,7 @@
 	sysarg_t rc;
 	aid_t req;
 
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	req = async_send_1(vfs_phone, VFS_IN_FSTAT, fildes, NULL);
@@ -486,16 +469,14 @@
 		sysarg_t rc_orig;
 		
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		if (rc_orig == EOK)
 			return (ssize_t) rc;
 		else
 			return (ssize_t) rc_orig;
 	}
 	async_wait_for(req, &rc);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 
 	return rc;
 }
@@ -511,16 +492,14 @@
 	if (!pa)
 		return ENOMEM;
 	
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	req = async_send_0(vfs_phone, VFS_IN_STAT, NULL);
 	rc = async_data_write_start(vfs_phone, pa, pa_size);
 	if (rc != EOK) {
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		free(pa);
 		if (rc_orig == EOK)
 			return (int) rc;
@@ -530,8 +509,7 @@
 	rc = async_data_read_start(vfs_phone, stat, sizeof(struct stat));
 	if (rc != EOK) {
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		free(pa);
 		if (rc_orig == EOK)
 			return (int) rc;
@@ -539,8 +517,7 @@
 			return (int) rc_orig;
 	}
 	async_wait_for(req, &rc);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	free(pa);
 	return rc;
 }
@@ -600,8 +577,7 @@
 	if (!pa)
 		return ENOMEM;
 	
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	req = async_send_1(vfs_phone, VFS_IN_MKDIR, mode, NULL);
@@ -610,8 +586,7 @@
 		sysarg_t rc_orig;
 	
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		free(pa);
 		if (rc_orig == EOK)
 			return (int) rc;
@@ -619,8 +594,7 @@
 			return (int) rc_orig;
 	}
 	async_wait_for(req, &rc);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	free(pa);
 	return rc;
 }
@@ -635,8 +609,7 @@
 	if (!pa)
 		return ENOMEM;
 
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	req = async_send_0(vfs_phone, VFS_IN_UNLINK, NULL);
@@ -645,8 +618,7 @@
 		sysarg_t rc_orig;
 
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		free(pa);
 		if (rc_orig == EOK)
 			return (int) rc;
@@ -654,8 +626,7 @@
 			return (int) rc_orig;
 	}
 	async_wait_for(req, &rc);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	free(pa);
 	return rc;
 }
@@ -688,16 +659,14 @@
 		return ENOMEM;
 	}
 
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	req = async_send_0(vfs_phone, VFS_IN_RENAME, NULL);
 	rc = async_data_write_start(vfs_phone, olda, olda_size);
 	if (rc != EOK) {
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		free(olda);
 		free(newa);
 		if (rc_orig == EOK)
@@ -708,8 +677,7 @@
 	rc = async_data_write_start(vfs_phone, newa, newa_size);
 	if (rc != EOK) {
 		async_wait_for(req, &rc_orig);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
+		vfs_serialize_end();
 		free(olda);
 		free(newa);
 		if (rc_orig == EOK)
@@ -718,8 +686,7 @@
 			return (int) rc_orig;
 	}
 	async_wait_for(req, &rc);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	free(olda);
 	free(newa);
 	return rc;
@@ -739,7 +706,7 @@
 		return ENOENT;
 	}
 	
-	futex_down(&cwd_futex);
+	fibril_mutex_lock(&cwd_mutex);
 	
 	if (cwd_fd >= 0)
 		close(cwd_fd);
@@ -752,7 +719,7 @@
 	cwd_path = abs;
 	cwd_size = abs_size;
 	
-	futex_up(&cwd_futex);
+	fibril_mutex_unlock(&cwd_mutex);
 	return EOK;
 }
 
@@ -761,15 +728,15 @@
 	if (size == 0)
 		return NULL;
 	
-	futex_down(&cwd_futex);
+	fibril_mutex_lock(&cwd_mutex);
 	
 	if ((cwd_size == 0) || (size < cwd_size + 1)) {
-		futex_up(&cwd_futex);
+		fibril_mutex_unlock(&cwd_mutex);
 		return NULL;
 	}
 	
 	str_cpy(buf, size, cwd_path);
-	futex_up(&cwd_futex);
+	fibril_mutex_unlock(&cwd_mutex);
 	
 	return buf;
 }
@@ -805,15 +772,13 @@
 
 int dup2(int oldfd, int newfd)
 {
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
+	vfs_serialize_start();
 	vfs_connect();
 	
 	sysarg_t ret;
 	sysarg_t rc = async_req_2_1(vfs_phone, VFS_IN_DUP, oldfd, newfd, &ret);
 	
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+	vfs_serialize_end();
 	
 	if (rc == EOK)
 		return (int) ret;

=== modified file 'uspace/srv/devman/devman.c'
--- uspace/srv/devman/devman.c	2010-12-21 16:07:59 +0000
+++ uspace/srv/devman/devman.c	2011-01-06 20:59:56 +0000
@@ -784,7 +784,7 @@
 	if (is_running) {
 		/* Notify the driver about the new device. */
 		int phone = async_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0);
-		if (phone > 0) {
+		if (phone >= 0) {
 			add_device(phone, drv, node, tree);
 			ipc_hangup(phone);
 		}

