Index: doc/arch/mips32
===================================================================
--- doc/arch/mips32	(revision 0bed5d07e4dcb9bc92ba8247c987b915e69ebe19)
+++ doc/arch/mips32	(revision 9cefba4b1f94a13c79f6ebc767ee59e56a86cbf8)
@@ -19,6 +19,5 @@
 
 EMULATORS AND VIRTUALIZERS
-	o msim 1.2.7
-        o msim 1.2.6 with lwl/lwr/swl/swr patch
+	o msim 1.2.8
         o gxemul - both big and little endian
         o simics 2.2.19
Index: include/proc/scheduler.h
===================================================================
--- include/proc/scheduler.h	(revision 0bed5d07e4dcb9bc92ba8247c987b915e69ebe19)
+++ include/proc/scheduler.h	(revision 9cefba4b1f94a13c79f6ebc767ee59e56a86cbf8)
@@ -40,6 +40,6 @@
 struct runq {
 	spinlock_t lock;
-	link_t rq_head;
-	int n;
+	link_t rq_head;		/**< List of ready threads. */
+	int n;			/**< Number of threads in rq_ready. */
 };
 
Index: include/proc/task.h
===================================================================
--- include/proc/task.h	(revision 0bed5d07e4dcb9bc92ba8247c987b915e69ebe19)
+++ include/proc/task.h	(revision 9cefba4b1f94a13c79f6ebc767ee59e56a86cbf8)
@@ -36,6 +36,6 @@
 struct task {
 	spinlock_t lock;
-	link_t th_head;		/* list of threads contained in this task */
-	link_t tasks_link;	/* link to other tasks within the system */
+	link_t th_head;		/**< List of threads contained in this task. */
+	link_t tasks_link;	/**< Link to other tasks within the system. */
 	vm_t *vm;
 };
Index: include/proc/thread.h
===================================================================
--- include/proc/thread.h	(revision 0bed5d07e4dcb9bc92ba8247c987b915e69ebe19)
+++ include/proc/thread.h	(revision 9cefba4b1f94a13c79f6ebc767ee59e56a86cbf8)
@@ -46,10 +46,10 @@
 
 enum state {
-	Invalid,
-	Running,
-	Sleeping,
-	Ready,
-	Entering,
-	Exiting
+	Invalid,	/**< It is an error, if thread is found in this state. */
+	Running,	/**< State of a thread that is currently executing on some CPU. */
+	Sleeping,	/**< Thread in this state is waiting for an event. */
+	Ready,		/**< State of threads in a run queue. */
+	Entering,	/**< Threads are in this state before they are first readied. */
+	Exiting		/**< After a thread calls thread_exit(), it is put into Exiting state. */
 };
 
@@ -60,17 +60,22 @@
 
 struct thread {
-	link_t rq_link;				/* run queue link */
-	link_t wq_link;				/* wait queue link */
-	link_t th_link;				/* links to threads within the parent task*/
-	link_t threads_link;
+	link_t rq_link;				/**< Run queue link. */
+	link_t wq_link;				/**< Wait queue link. */
+	link_t th_link;				/**< Links to threads within containing task. */
+	link_t threads_link;			/**< Link to the list of all threads. */
 	
 	/* items below are protected by lock */
 	spinlock_t lock;
 
-	void (* thread_code)(void *);
-	void *thread_arg;
+	void (* thread_code)(void *);		/**< Function implementing the thread. */
+	void *thread_arg;			/**< Argument passed to thread_code() function. */
 
-	context_t saved_context;
-	context_t sleep_timeout_context;
+	context_t saved_context;		/**< From here, the stored context is restored when the thread is scheduled. */
+	context_t sleep_timeout_context;	/**< From here, the stored failover context is restored when sleep times out. */
+
+	waitq_t *sleep_queue;			/**< Wait queue in which this thread sleeps. */
+	timeout_t sleep_timeout;		/**< Timeout used for timeoutable sleeping.  */
+	volatile int timeout_pending;		/**< Flag signalling sleep timeout in progress. */
+
 	fpu_context_t saved_fpu_context;
 	int fpu_context_exists;
@@ -83,32 +88,28 @@
 	int fpu_context_engaged;
 
-	waitq_t *sleep_queue;
-	timeout_t sleep_timeout;
-	volatile int timeout_pending;
+	rwlock_type_t rwlock_holder_type;
 
-	rwlock_type_t rwlock_holder_type;
-	void (* call_me)(void *);
-	void *call_me_with;
+	void (* call_me)(void *);		/**< Funtion to be called in scheduler before the thread is put asleep. */
+	void *call_me_with;			/**< Argument passed to call_me(). */
 
-	int state;
-	int flags;
+	state_t state;				/**< Thread's state. */
+	int flags;				/**< Thread's flags. */
 	
-	cpu_t *cpu;
-	task_t *task;
+	cpu_t *cpu;				/**< Thread's CPU. */
+	task_t *task;				/**< Containing task. */
 
-	__u64 ticks;
+	__u64 ticks;				/**< Ticks before preemption. */
 
-	__u32 tid;
+	int pri;				/**< Thread's priority. Implemented as index of run queue. */
+	__u32 tid;				/**< Thread ID. */
 	
-	int pri;
-	
-	ARCH_THREAD_DATA;
+	ARCH_THREAD_DATA;			/**< Architecture-specific data. */
 
-	__u8 *kstack;
-	__u8 *ustack;
+	__u8 *kstack;				/**< Thread's kernel stack. */
+	__u8 *ustack;				/**< Thread's user stack. */
 };
 
-extern spinlock_t threads_lock;
-extern link_t threads_head;
+extern spinlock_t threads_lock;			/**< Lock protecting threads_head list. */
+extern link_t threads_head;			/**< List of all threads in the system. */
 
 static void cushion(void);
Index: include/synch/rwlock.h
===================================================================
--- include/synch/rwlock.h	(revision 0bed5d07e4dcb9bc92ba8247c987b915e69ebe19)
+++ include/synch/rwlock.h	(revision 9cefba4b1f94a13c79f6ebc767ee59e56a86cbf8)
@@ -43,6 +43,6 @@
 struct rwlock {
 	spinlock_t lock;
-	mutex_t exclusive;
-	int readers_in;
+	mutex_t exclusive;	/**< Mutex for writers, readers can bypass it if readers_in is positive. */
+	int readers_in;		/**< Number of readers in critical section. */
 };
 
Index: include/synch/synch.h
===================================================================
--- include/synch/synch.h	(revision 0bed5d07e4dcb9bc92ba8247c987b915e69ebe19)
+++ include/synch/synch.h	(revision 9cefba4b1f94a13c79f6ebc767ee59e56a86cbf8)
@@ -30,12 +30,12 @@
 #define __SYNCH_H__
 
-#define SYNCH_NO_TIMEOUT	0
-#define SYNCH_BLOCKING		0
-#define SYNCH_NON_BLOCKING	1
+#define SYNCH_NO_TIMEOUT	0	/**< No timeout is request. */
+#define SYNCH_BLOCKING		0	/**< Blocking operation request. */
+#define SYNCH_NON_BLOCKING	1	/**< Non-blocking operation request. */
 
-#define ESYNCH_WOULD_BLOCK	1
-#define ESYNCH_TIMEOUT		2
-#define ESYNCH_OK_ATOMIC	4
-#define ESYNCH_OK_BLOCKED	8
+#define ESYNCH_WOULD_BLOCK	1	/**< Could not satisfy the request without going to sleep. */
+#define ESYNCH_TIMEOUT		2	/**< Timeout occurred. */
+#define ESYNCH_OK_ATOMIC	4	/**< Operation succeeded without sleeping. */
+#define ESYNCH_OK_BLOCKED	8	/**< Operation succeeded and did sleep. */
 
 #define SYNCH_FAILED(rc)	((rc) & (ESYNCH_WOULD_BLOCK | ESYNCH_TIMEOUT))
Index: include/synch/waitq.h
===================================================================
--- include/synch/waitq.h	(revision 0bed5d07e4dcb9bc92ba8247c987b915e69ebe19)
+++ include/synch/waitq.h	(revision 9cefba4b1f94a13c79f6ebc767ee59e56a86cbf8)
@@ -41,6 +41,6 @@
 struct waitq {
 	spinlock_t lock;
-	int missed_wakeups;
-	link_t head;
+	int missed_wakeups;	/**< Number of waitq_wakeup() calls that didn't find a thread to wake up. */
+	link_t head;		/**< List of sleeping threads for wich there was no missed_wakeup. */
 };
 
Index: include/typedefs.h
===================================================================
--- include/typedefs.h	(revision 0bed5d07e4dcb9bc92ba8247c987b915e69ebe19)
+++ include/typedefs.h	(revision 9cefba4b1f94a13c79f6ebc767ee59e56a86cbf8)
@@ -46,4 +46,5 @@
 typedef struct cpu_arch cpu_arch_t;
 typedef struct task task_t;
+typedef enum state state_t;
 typedef struct thread thread_t;
 typedef struct context context_t;
