synch chan

SVN=127055
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index 4273f16..0b2e8ed 100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -42,6 +42,7 @@
 typedef	struct	M		M;
 typedef struct	Stktop		Stktop;
 typedef	struct	Alg		Alg;
+typedef	struct	WaitQ		WaitQ;
 
 /*
  * per cpu declaration
@@ -57,6 +58,7 @@
 	// G status
 	Gidle,
 	Grunnable,
+	Gwaiting,
 	Gdead,
 };
 enum
@@ -104,10 +106,12 @@
 	byte*	stackguard;	// must not move
 	byte*	stackbase;	// must not move
 	Gobuf	sched;
-	G*	link;
+	G*	alllink;	// on allq
+	G*	qlink;		// on wait q
 	int32	status;
 	int32	pri;
 	int32	goid;
+	byte	elem[8];	// transfer element for chan
 };
 struct	M
 {
@@ -121,7 +125,12 @@
 	int32	siz1;
 	int32	siz2;
 };
-struct Stktop
+struct	WaitQ
+{
+	G*	first;
+	G*	last;
+};
+struct	Stktop
 {
 	uint8*	oldbase;
 	uint8*	oldsp;
@@ -166,6 +175,8 @@
 void	dump(byte*, int32);
 int32	runetochar(byte*, int32);
 int32	chartorune(uint32*, byte*);
+G*	dequeue(WaitQ*);
+void	enqueue(WaitQ*, G*);
 
 /*
  * very low level c-called