Nice automatic updates up to a point, then renice if necessary.

BUG=5488
TEST=unit tests, gmerged on device and completed an update
successfully with two 100% CPU "nice -n -20" processes
running in the background.

Review URL: http://codereview.chromium.org/3053049
diff --git a/utils.cc b/utils.cc
index 05acc15..134ad80 100644
--- a/utils.cc
+++ b/utils.cc
@@ -5,6 +5,7 @@
 #include "update_engine/utils.h"
 
 #include <sys/mount.h>
+#include <sys/resource.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <dirent.h>
@@ -444,6 +445,18 @@
   return true;
 }
 
+bool SetProcessPriority(ProcessPriority priority) {
+  int prio = static_cast<int>(priority);
+  LOG(INFO) << "Setting process priority to " << prio;
+  TEST_AND_RETURN_FALSE(setpriority(PRIO_PROCESS, 0, prio) == 0);
+  return true;
+}
+
+int ComparePriorities(ProcessPriority priority_lhs,
+                      ProcessPriority priority_rhs) {
+  return static_cast<int>(priority_rhs) - static_cast<int>(priority_lhs);
+}
+
 const char* const kStatefulPartition = "/mnt/stateful_partition";
 
 }  // namespace utils