diff -urNp ref/arch/i386/kernel/entry.S 2.4.20pre7aa1/arch/i386/kernel/entry.S
--- ref/arch/i386/kernel/entry.S	Fri Sep 13 06:13:34 2002
+++ 2.4.20pre7aa1/arch/i386/kernel/entry.S	Tue Sep 17 23:59:39 2002
@@ -637,8 +637,8 @@ ENTRY(sys_call_table)
  	.long SYMBOL_NAME(sys_tkill)
 	.long SYMBOL_NAME(sys_ni_syscall)	/* reserved for sendfile64 */
 	.long SYMBOL_NAME(sys_ni_syscall)	/* 240 reserved for futex */
-	.long SYMBOL_NAME(sys_ni_syscall)	/* reserved for sched_setaffinity */
-	.long SYMBOL_NAME(sys_ni_syscall)	/* reserved for sched_getaffinity */
+	.long SYMBOL_NAME(sys_sched_setaffinity)
+	.long SYMBOL_NAME(sys_sched_getaffinity)
 	.long SYMBOL_NAME(sys_ni_syscall)	/* sys_set_thread_area */
 	.long SYMBOL_NAME(sys_ni_syscall)	/* sys_get_thread_area */
 	.long SYMBOL_NAME(sys_ni_syscall)	/* 245 sys_io_setup */
diff -urNp ref/arch/ppc/kernel/misc.S 2.4.20pre7aa1/arch/ppc/kernel/misc.S
--- ref/arch/ppc/kernel/misc.S	Fri Sep 13 06:13:38 2002
+++ 2.4.20pre7aa1/arch/ppc/kernel/misc.S	Tue Sep 17 23:59:53 2002
@@ -1172,8 +1172,8 @@ _GLOBAL(sys_call_table)
 	.long sys_lremovexattr
 	.long sys_fremovexattr	/* 220  */
 	.long sys_ni_syscall 	/*	reserved for sys_futex */
-	.long sys_ni_syscall 	/*	reserved for sys_sched_setaffinity */
-	.long sys_ni_syscall 	/*	reserved for sys_sched_getaffinity */
+	.long sys_sched_setaffinity
+	.long sys_sched_getaffinity
 	.long sys_ni_syscall 	/*	reserved for sys_security */
 	.long sys_ni_syscall 	/* 225	reserved for Tux */
 	.long sys_ni_syscall 	/*	reserved for sys_sendfile64 */
diff -urNp ref/include/asm-ppc/unistd.h 2.4.20pre7aa1/include/asm-ppc/unistd.h
--- ref/include/asm-ppc/unistd.h	Fri Sep 13 06:13:55 2002
+++ 2.4.20pre7aa1/include/asm-ppc/unistd.h	Wed Sep 18 00:00:16 2002
@@ -228,7 +228,6 @@
 #define __NR_removexattr	218
 #define __NR_lremovexattr	219
 #define __NR_fremovexattr	220
-#if 0
 #define __NR_futex		221
 #define __NR_sched_setaffinity	222
 #define __NR_sched_getaffinity	223
@@ -240,7 +239,6 @@
 #define __NR_io_getevents	229
 #define __NR_io_submit		230
 #define __NR_io_cancel		231
-#endif
 
 #define __NR(n)	#n
 
diff -urNp ref/include/linux/capability.h 2.4.20pre7aa1/include/linux/capability.h
--- ref/include/linux/capability.h	Tue Jul 16 23:56:42 2002
+++ 2.4.20pre7aa1/include/linux/capability.h	Tue Sep 17 23:59:24 2002
@@ -243,6 +243,7 @@ typedef __u32 kernel_cap_t;
 /* Allow use of FIFO and round-robin (realtime) scheduling on own
    processes and setting the scheduling algorithm used by another
    process. */
+/* Allow setting cpu affinity on other processes */
 
 #define CAP_SYS_NICE         23
 
diff -urNp ref/kernel/sched.c 2.4.20pre7aa1/kernel/sched.c
--- ref/kernel/sched.c	Fri Sep 13 06:13:57 2002
+++ 2.4.20pre7aa1/kernel/sched.c	Tue Sep 17 23:59:24 2002
@@ -1026,6 +1026,97 @@ out_unlock:
 	return retval;
 }
 
+/**
+ * sys_sched_setaffinity - set the cpu affinity of a process
+ * @pid: pid of the process
+ * @len: length in bytes of the bitmask pointed to by user_mask_ptr
+ * @user_mask_ptr: user-space pointer to the new cpu mask
+ */
+asmlinkage int sys_sched_setaffinity(pid_t pid, unsigned int len,
+				     unsigned long *user_mask_ptr)
+{
+	unsigned long new_mask;
+	task_t *p;
+	int retval;
+
+	if (len < sizeof(new_mask))
+		return -EINVAL;
+
+	if (copy_from_user(&new_mask, user_mask_ptr, sizeof(new_mask)))
+		return -EFAULT;
+
+	new_mask &= cpu_online_map;
+	if (!new_mask)
+		return -EINVAL;
+
+	/*
+	 * We cannot hold a lock across a call to set_cpus_allowed, however
+	 * we need to assure our task does not slip out from under us.  Since
+	 * we are only concerned that its task_struct remains, we can pin it
+	 * here and decrement the usage count when we are done.
+	 */
+	read_lock(&tasklist_lock);
+
+	p = find_process_by_pid(pid);
+	if (!p) {
+		read_unlock(&tasklist_lock);
+		return -ESRCH;
+	}
+
+	get_task_struct(p);
+	read_unlock(&tasklist_lock);
+
+	retval = -EPERM;
+	if ((current->euid != p->euid) && (current->euid != p->uid) &&
+			!capable(CAP_SYS_NICE))
+		goto out_unlock;
+
+	retval = 0;
+	set_cpus_allowed(p, new_mask);
+
+out_unlock:
+	free_task_struct(p);
+	return retval;
+}
+
+/**
+ * sys_sched_getaffinity - get the cpu affinity of a process
+ * @pid: pid of the process
+ * @len: length in bytes of the bitmask pointed to by user_mask_ptr
+ * @user_mask_ptr: user-space pointer to hold the current cpu mask
+ */
+asmlinkage int sys_sched_getaffinity(pid_t pid, unsigned int len,
+				     unsigned long *user_mask_ptr)
+{
+	unsigned long mask;
+	unsigned int real_len;
+	task_t *p;
+	int retval;
+
+	real_len = sizeof(mask);
+
+	if (len < real_len)
+		return -EINVAL;
+
+	read_lock(&tasklist_lock);
+
+	retval = -ESRCH;
+	p = find_process_by_pid(pid);
+	if (!p)
+		goto out_unlock;
+
+	retval = 0;
+	mask = p->cpus_allowed & cpu_online_map;
+
+out_unlock:
+	read_unlock(&tasklist_lock);
+	if (retval)
+		return retval;
+	if (copy_to_user(user_mask_ptr, &mask, real_len))
+		return -EFAULT;
+	return real_len;
+}
+
 asmlinkage long sys_sched_yield(void)
 {
 	/*