Index: src/Concurrency/Keywords.cc
===================================================================
--- src/Concurrency/Keywords.cc	(revision 9f5a19faedb38ca69f5dbc95f44edc41fdda370b)
+++ src/Concurrency/Keywords.cc	(revision 1b97976c642f3a6d89db6c57bbf763b7b73bd784)
@@ -93,4 +93,5 @@
 		ObjectDecl * addField( StructDecl * );
 		void addRoutines( ObjectDecl *, FunctionDecl * );
+		void addLockUnlockRoutines( StructDecl * );
 
 		virtual bool is_target( StructDecl * decl ) = 0;
@@ -322,4 +323,5 @@
 		StructDecl* dtor_guard_decl = nullptr;
 		StructDecl* thread_guard_decl = nullptr;
+		StructDecl* lock_guard_decl = nullptr;
 
 		static std::unique_ptr< Type > generic_func;
@@ -463,5 +465,4 @@
 	}
 
-
 	void ConcurrentSueKeyword::handle( StructDecl * decl ) {
 		if( ! decl->body ) return;
@@ -479,5 +480,9 @@
 		FunctionDecl * func = forwardDeclare( decl );
 		ObjectDecl * field = addField( decl );
+
+		// add get_.* routine
 		addRoutines( field, func );
+		// add lock/unlock routines to monitors for use by mutex stmt
+		addLockUnlockRoutines( decl );
 	}
 
@@ -612,4 +617,6 @@
 	}
 
+	// This function adds the get_.* routine body for coroutines, monitors etc
+	// 		after their corresponding struct has been made
 	void ConcurrentSueKeyword::addRoutines( ObjectDecl * field, FunctionDecl * func ) {
 		CompoundStmt * statement = new CompoundStmt();
@@ -634,4 +641,112 @@
 
 		declsToAddAfter.push_back( get_decl );
+	}
+
+	// Generates lock/unlock routines for monitors to be used by mutex stmts
+	void ConcurrentSueKeyword::addLockUnlockRoutines( StructDecl * decl ) {
+		// this routine will be called for all ConcurrentSueKeyword children so only continue if we are a monitor
+		if ( !decl->is_monitor() ) return;
+
+		FunctionType * lock_fn_type = new FunctionType( noQualifiers, false );
+		FunctionType * unlock_fn_type = new FunctionType( noQualifiers, false );
+
+		// create this ptr parameter for both routines
+		ObjectDecl * this_decl = new ObjectDecl(
+			"this",
+			noStorageClasses,
+			LinkageSpec::Cforall,
+			nullptr,
+			new ReferenceType(
+				noQualifiers,
+				new StructInstType(
+					noQualifiers,
+					decl
+				)
+			),
+			nullptr
+		);
+
+		lock_fn_type->get_parameters().push_back( this_decl->clone() );
+		unlock_fn_type->get_parameters().push_back( this_decl->clone() );
+
+		delete this_decl;
+
+
+		//////////////////////////////////////////////////////////////////////
+		// The following generates this lock routine for all monitors
+		/*
+			void lock (monitor_t & this) {
+				lock(get_monitor(this));
+			}	
+		*/
+		FunctionDecl * lock_decl = new FunctionDecl(
+			"lock",
+			Type::Static,
+			LinkageSpec::Cforall,
+			lock_fn_type,
+			nullptr,
+			{ },
+			Type::Inline
+		);
+		fixupGenerics(lock_fn_type, decl);
+
+		UntypedExpr * get_monitor_lock =  new UntypedExpr (
+			new NameExpr( "get_monitor" ),
+			{ new VariableExpr( lock_fn_type->get_parameters().front() ) }
+		);
+
+		CompoundStmt * lock_statement = new CompoundStmt();
+		lock_statement->push_back(
+			new ExprStmt( 
+				new UntypedExpr (
+					new NameExpr( "lock" ),
+					{
+						get_monitor_lock
+					}
+				)
+			)
+		);
+		lock_decl->set_statements( lock_statement );
+
+		//////////////////////////////////////////////////////////////////
+		// The following generates this routine for all monitors
+		/*
+			void unlock (monitor_t & this) {
+				unlock(get_monitor(this));
+			}	
+		*/
+		FunctionDecl * unlock_decl = new FunctionDecl(
+			"unlock",
+			Type::Static,
+			LinkageSpec::Cforall,
+			unlock_fn_type,
+			nullptr,
+			{ },
+			Type::Inline
+		);
+		fixupGenerics(unlock_fn_type, decl);
+
+		CompoundStmt * unlock_statement = new CompoundStmt();
+
+		UntypedExpr * get_monitor_unlock =  new UntypedExpr (
+			new NameExpr( "get_monitor" ),
+			{ new VariableExpr( unlock_fn_type->get_parameters().front() ) }
+		);
+
+		unlock_statement->push_back(
+			new ExprStmt( 
+				new UntypedExpr(
+					new NameExpr( "unlock" ),
+					{
+						get_monitor_unlock
+					}
+				)
+			)
+		);
+		unlock_decl->set_statements( unlock_statement );
+		
+		// pushes routines to declsToAddAfter to add at a later time
+		declsToAddAfter.push_back( lock_decl );
+		declsToAddAfter.push_back( unlock_decl );
 	}
 
@@ -937,4 +1052,8 @@
 			assert( !thread_guard_decl );
 			thread_guard_decl = decl;
+		} 
+		else if ( decl->name == "__mutex_stmt_lock_guard" && decl->body ) {
+			assert( !lock_guard_decl );
+			lock_guard_decl = decl;
 		}
 	}
@@ -1081,8 +1200,5 @@
 				new PointerType(
 					noQualifiers,
-					new StructInstType(
-						noQualifiers,
-						monitor_decl
-					)
+					new TypeofType( noQualifiers, args.front()->clone() )
 				),
 				new ConstantExpr( Constant::from_ulong( args.size() ) ),
@@ -1093,5 +1209,5 @@
 				map_range < std::list<Initializer*> > ( args, [](Expression * var ){
 					return new SingleInit( new UntypedExpr(
-						new NameExpr( "get_monitor" ),
+						new NameExpr( "__get_pointer" ),
 						{ var }
 					) );
@@ -1099,4 +1215,9 @@
 			)
 		);
+
+		StructInstType * lock_guard_struct = new StructInstType( noQualifiers, lock_guard_decl );
+		TypeExpr * lock_type_expr = new TypeExpr( new TypeofType( noQualifiers, args.front()->clone() ) );
+
+		lock_guard_struct->parameters.push_back( lock_type_expr ) ;
 
 		// in reverse order :
@@ -1108,8 +1229,5 @@
 				LinkageSpec::Cforall,
 				nullptr,
-				new StructInstType(
-					noQualifiers,
-					guard_decl
-				),
+				lock_guard_struct,
 				new ListInit(
 					{
