public synchronized ArrayDeque<MapTask> assignMapTask(int slaveID,
			int taskNum) {
		ArrayDeque<MapTask> tasks = new ArrayDeque<MapTask>();
		ArrayDeque<MapTask> potential = slaveMapTaskList.get(slaveID);
		if (potential != null && potential.size() > 0) {
			for (int i = 0; i < taskNum; i++) {
				MapTask task;
				int jobID = 0;
				HashSet<Task> t = new HashSet<Task>();
				// check if the task has been assigned to other slaves
				do {
					task = potential.pollFirst();
					if (task == null)
						break;
					jobID = task.getJob().getId();
					t = jobAssignedTask.get(jobID);
				} while (t.contains(task));
				if (task == null) {
					break;
				}
				// add unassigned task to return value
				tasks.add(task);
				// add the task to slave to task running list
				HashSet<MapTask> taskList = slaveRunningTask.get(slaveID);
				taskList.add(task);
				slaveRunningTask.put(slaveID, taskList);
				// add the job and task to assigned list
				t.add(task);
				jobAssignedTask.put(jobID, t);
			}
		}
		return tasks;
	}