Index: src/Common/utility.h
===================================================================
--- src/Common/utility.h	(revision 08d5507b99eb502f8fb69133c61233301ed6b029)
+++ src/Common/utility.h	(revision 4da6a6c62c48d6182b9a9e4567acfd2fb4311701)
@@ -265,4 +265,18 @@
 reverse_iterate_t< T > reverseIterate( T & ref ) {
 	return reverse_iterate_t< T >( ref );
+}
+
+template< typename OutType, typename Range, typename Functor >
+OutType map_range( const Range& range, Functor&& functor ) {
+	OutType out;
+
+	std::transform(
+		begin( range ),
+		end( range ),
+		std::back_inserter( out ),
+		std::forward< Functor >( functor )
+	);
+
+	return out;
 }
 
Index: src/Concurrency/Keywords.cc
===================================================================
--- src/Concurrency/Keywords.cc	(revision 08d5507b99eb502f8fb69133c61233301ed6b029)
+++ src/Concurrency/Keywords.cc	(revision 4da6a6c62c48d6182b9a9e4567acfd2fb4311701)
@@ -0,0 +1,218 @@
+//                              -*- Mode: CPP -*-
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// Keywords.cc --
+//
+// Author           : Thierry Delisle
+// Created On       : Mon Mar 13 12:41:22 2017
+// Last Modified By :
+// Last Modified On :
+// Update Count     : 0
+//
+
+#include "Concurrency/Keywords.h"
+
+#include "SynTree/Declaration.h"
+#include "SynTree/Expression.h"
+#include "SynTree/Initializer.h"
+#include "SynTree/Mutator.h"
+#include "SynTree/Statement.h"
+#include "SynTree/Type.h"
+#include "SynTree/Visitor.h"
+
+namespace Concurrency {
+
+	namespace {
+		const std::list<Label> noLabels;
+		DeclarationNode::StorageClasses noStorage;
+		Type::Qualifiers noQualifiers;
+	}
+
+	//=============================================================================================
+	// Visitors declaration
+	//=============================================================================================
+
+	//-----------------------------------------------------------------------------
+	//Handles thread type declarations :
+	// thread Mythread {                         struct MyThread {
+	// 	int data;                                  int data;
+	// 	a_struct_t more_data;                      a_struct_t more_data;
+	//                                =>             thread_desc __thrd_d;
+	// };                                        };
+	//                                           static inline thread_desc * get_thread( MyThread * this ) { return &this->__thrd_d; }
+	//                                           void main( MyThread * this );
+	//
+	class ThreadKeyword final : public Mutator {
+	  public:
+
+		static void implement( std::list< Declaration * > & translationUnit ) {}
+	};
+
+	//-----------------------------------------------------------------------------
+	//Handles coroutine type declarations :
+	// coroutine MyCoroutine {                   struct MyCoroutine {
+	// 	int data;                                  int data;
+	// 	a_struct_t more_data;                      a_struct_t more_data;
+	//                                =>             coroutine_desc __cor_d;
+	// };                                        };
+	//                                           static inline coroutine_desc * get_coroutine( MyCoroutine * this ) { return &this->__cor_d; }
+	//                                           void main( MyCoroutine * this );
+	//
+	class CoroutineKeyword final : public Mutator {
+	  public:
+
+		static void implement( std::list< Declaration * > & translationUnit ) {}
+	};
+
+	//-----------------------------------------------------------------------------
+	//Handles monitor type declarations :
+	// monitor MyMonitor {                       struct MyMonitor {
+	// 	int data;                                  int data;
+	// 	a_struct_t more_data;                      a_struct_t more_data;
+	//                                =>             monitor_desc __mon_d;
+	// };                                        };
+	//                                           static inline monitor_desc * get_coroutine( MyMonitor * this ) { return &this->__cor_d; }
+	//                                           void main( MyMonitor * this );
+	//
+	class MonitorKeyword final : public Mutator {
+	  public:
+
+		static void implement( std::list< Declaration * > & translationUnit ) {}
+	};
+
+	//-----------------------------------------------------------------------------
+	//Handles mutex routines definitions :
+	// void foo( A * mutex a, B * mutex b,  int i ) {                  void foo( A * a, B * b,  int i ) {
+	// 	                                                                 monitor_desc * __monitors[] = { a, b };
+	// 	                                                                 monitor_guard_t __guard = { __monitors, 2 };
+	//    /*Some code*/                                       =>           /*Some code*/
+	// }                                                               }
+	//
+	class MutexKeyword final : public Visitor {
+	  public:
+
+		using Visitor::visit;
+		virtual void visit( FunctionDecl *functionDecl ) override final;
+
+		std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* );
+		void validate( DeclarationWithType * );
+		void addStatments( CompoundStmt *, const std::list<DeclarationWithType * > &);
+
+		static void implement( std::list< Declaration * > & translationUnit ) {
+			MutexKeyword impl;
+			acceptAll( translationUnit, impl );
+		}
+	};
+
+	//=============================================================================================
+	// General entry routine
+	//=============================================================================================
+	void applyKeywords( std::list< Declaration * > & translationUnit ) {
+		ThreadKeyword	::implement( translationUnit );
+		CoroutineKeyword	::implement( translationUnit );
+		MonitorKeyword	::implement( translationUnit );
+		MutexKeyword	::implement( translationUnit );
+	}
+
+	//=============================================================================================
+	// Mutex keyword implementation
+	//=============================================================================================
+	void MutexKeyword::visit(FunctionDecl* decl) {
+		std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl );
+		if( mutexArgs.empty() ) return;
+
+		for(auto arg : mutexArgs) {
+			validate( arg );
+		}
+
+		CompoundStmt* body = decl->get_statements();
+		if( ! body ) return;
+
+		addStatments( body, mutexArgs );
+	}
+
+	std::list<DeclarationWithType*> MutexKeyword::findMutexArgs( FunctionDecl* decl ) {
+		std::list<DeclarationWithType*> mutexArgs;
+
+		for( auto arg : decl->get_functionType()->get_parameters()) {
+			//Find mutex arguments
+			Type* ty = arg->get_type();
+			if( ! ty->get_qualifiers().isMutex ) continue;
+
+			//Append it to the list
+			mutexArgs.push_back( arg );
+		}
+
+		return mutexArgs;
+	}
+
+	void MutexKeyword::validate( DeclarationWithType * arg ) {
+		Type* ty = arg->get_type();
+
+		//Makes sure it's not a copy
+		PointerType* pty = dynamic_cast< PointerType * >( ty );
+		if( ! pty ) throw SemanticError( "Mutex argument must be of pointer/reference type ", arg );
+
+		//Make sure the we are pointing directly to a type
+		Type* base = pty->get_base();
+		if(  dynamic_cast< PointerType * >( base ) ) throw SemanticError( "Mutex argument have exactly one level of indirection ", arg );
+
+		//Make sure that typed isn't mutex
+		if( ! base->get_qualifiers().isMutex ) throw SemanticError( "mutex keyword may only appear once per argument ", arg );
+	}
+
+	void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) {
+		//in reverse order :
+		// monitor_guard_t __guard = { __monitors, # };
+		body->push_front(
+			new DeclStmt( noLabels, new ObjectDecl(
+				"__guard",
+				noStorage,
+				LinkageSpec::Cforall,
+				nullptr,
+				new StructInstType(
+					noQualifiers,
+					"monitor_guard_t"
+				),
+				new ListInit(
+					{
+						new SingleInit( new NameExpr( "__monitors" ) ),
+						new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) )
+					}
+				)
+			))
+		);
+
+		//monitor_desc * __monitors[] = { a, b };
+		body->push_front(
+			new DeclStmt( noLabels, new ObjectDecl(
+				"__monitors",
+				noStorage,
+				LinkageSpec::Cforall,
+				nullptr,
+				new ArrayType(
+					noQualifiers,
+					new PointerType(
+						noQualifiers,
+						new StructInstType(
+							noQualifiers,
+							"monitor_desc"
+						)
+					),
+					new ConstantExpr( Constant::from_ulong( args.size() ) ),
+					false,
+					false
+				),
+				new ListInit(
+					map_range < std::list<Initializer*> > ( args, [](DeclarationWithType * var ){
+						return new SingleInit( new VariableExpr( var ) );
+					})
+				)
+			))
+		);
+	}
+};
Index: src/Concurrency/Keywords.h
===================================================================
--- src/Concurrency/Keywords.h	(revision 08d5507b99eb502f8fb69133c61233301ed6b029)
+++ src/Concurrency/Keywords.h	(revision 4da6a6c62c48d6182b9a9e4567acfd2fb4311701)
@@ -0,0 +1,28 @@
+//                              -*- Mode: CPP -*-
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// Keywords.h --
+//
+// Author           : Thierry Delisle
+// Created On       : Fri Mar 10 15:16:42 2017
+// Last Modified By :
+// Last Modified On :
+// Update Count     : 0
+//
+
+#ifndef KEYWORDS_H
+#define KEYWORDS_H
+
+#include <list>
+
+#include "SynTree/Declaration.h"
+
+namespace Concurrency {
+	void applyKeywords( std::list< Declaration * > & translationUnit );
+};
+
+#endif //KEYWORDS_H
Index: src/SymTab/Autogen.h
===================================================================
--- src/SymTab/Autogen.h	(revision 08d5507b99eb502f8fb69133c61233301ed6b029)
+++ src/SymTab/Autogen.h	(revision 4da6a6c62c48d6182b9a9e4567acfd2fb4311701)
@@ -58,5 +58,5 @@
 			assert( type );
 			Type * castType = type->clone();
-			castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true);
+			castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false);
 			castType->set_isLvalue( true ); // xxx - might not need this
 			dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
Index: src/SymTab/Validate.cc
===================================================================
--- src/SymTab/Validate.cc	(revision 08d5507b99eb502f8fb69133c61233301ed6b029)
+++ src/SymTab/Validate.cc	(revision 4da6a6c62c48d6182b9a9e4567acfd2fb4311701)
@@ -323,5 +323,5 @@
 			ObjectDecl * obj = dynamic_cast< ObjectDecl * >( *i );
 			assert( obj );
-			obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false ), enumDecl->get_name() ) );
+			obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false, false ), enumDecl->get_name() ) );
 		} // for
 		Parent::visit( enumDecl );
Index: src/SynTree/Type.h
===================================================================
--- src/SynTree/Type.h	(revision 08d5507b99eb502f8fb69133c61233301ed6b029)
+++ src/SynTree/Type.h	(revision 4da6a6c62c48d6182b9a9e4567acfd2fb4311701)
@@ -25,6 +25,6 @@
   public:
 	struct Qualifiers {
-		Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ) {}
-		Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ) {}
+		Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isMutex( false ) {}
+		Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isMutex ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isMutex( isMutex ) {}
 
 		Qualifiers &operator&=( const Qualifiers &other );
@@ -45,4 +45,5 @@
 		bool isLvalue;
 		bool isAtomic;
+		bool isMutex;
 	};
 
@@ -511,4 +512,5 @@
 	isLvalue &= other.isLvalue;
 	isAtomic &= other.isAtomic;
+	isMutex &= other.isMutex;
 	return *this;
 }
@@ -520,4 +522,5 @@
 	isLvalue |= other.isLvalue;
 	isAtomic |= other.isAtomic;
+	isMutex |= other.isMutex;
 	return *this;
 }
@@ -528,4 +531,5 @@
 	if ( other.isRestrict ) isRestrict = 0;
 	if ( other.isAtomic ) isAtomic = 0;
+	if ( other.isMutex ) isMutex = 0;
 	return *this;
 }
Index: src/Tuples/TupleAssignment.cc
===================================================================
--- src/Tuples/TupleAssignment.cc	(revision 08d5507b99eb502f8fb69133c61233301ed6b029)
+++ src/Tuples/TupleAssignment.cc	(revision 4da6a6c62c48d6182b9a9e4567acfd2fb4311701)
@@ -199,5 +199,5 @@
 				Type * type = InitTweak::getPointerBase( castType );
 				assert( type );
-				type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true);
+				type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false);
 				type->set_isLvalue( true ); // xxx - might not need this
 				expr = new CastExpr( expr, castType );
Index: src/Tuples/TupleExpansion.cc
===================================================================
--- src/Tuples/TupleExpansion.cc	(revision 08d5507b99eb502f8fb69133c61233301ed6b029)
+++ src/Tuples/TupleExpansion.cc	(revision 4da6a6c62c48d6182b9a9e4567acfd2fb4311701)
@@ -305,5 +305,5 @@
 	Type * makeTupleType( const std::list< Expression * > & exprs ) {
 		// produce the TupleType which aggregates the types of the exprs
-		TupleType *tupleType = new TupleType( Type::Qualifiers(true, true, true, true, true) );
+		TupleType *tupleType = new TupleType( Type::Qualifiers(true, true, true, true, true, true) );
 		Type::Qualifiers &qualifiers = tupleType->get_qualifiers();
 		for ( Expression * expr : exprs ) {
Index: src/main.cc
===================================================================
--- src/main.cc	(revision 08d5507b99eb502f8fb69133c61233301ed6b029)
+++ src/main.cc	(revision 4da6a6c62c48d6182b9a9e4567acfd2fb4311701)
@@ -32,4 +32,5 @@
 #include "GenPoly/CopyParams.h"
 #include "GenPoly/InstantiateGeneric.h"
+#include "Concurrency/Keywords.h"
 #include "CodeGen/Generate.h"
 #include "CodeGen/FixNames.h"
@@ -236,4 +237,6 @@
 		OPTPRINT( "mutate" )
 		ControlStruct::mutate( translationUnit );
+		OPTPRINT( "Concurrency" )
+		Concurrency::applyKeywords( translationUnit );
 		OPTPRINT( "fixNames" )
 		CodeGen::fixNames( translationUnit );
