Commit Graph

23 Commits

Author SHA1 Message Date
Mathias Agopian 2bd99599bb split utils/threads.h into multiple headers
AndroidDefs.h - C/C++ enums and types
Mutex.h - Mutex class declaration
Condition.h - Condition class declaration
RWLock.h - RWLock class declaration
Thread.h - Thread class declaration
AndroidThreads.h - low-level thread creation functions
threads.h - includes all the above for backward source compatibility

Change-Id: Ia2f80c175333b59a41d1720985810bb2346e94cb
Note: implementations are still in Threads.cpp
2013-07-30 13:56:59 -07:00
Glenn Kasten d731f07cc9 Thread::getTid returns pid_t gettid() after run
This is needed when the parent or any other thread besides the child
needs access to the child's kernel tid.

Change-Id: Ib148505913eb78314cfd76657c30d7b20663dffd
2013-07-30 13:56:58 -07:00
Andreas Huber 8ddbed9efd A new API "androidGetThreadPriority"
Change-Id: I6baeead8c70460863343fd557250635fb1e6a170
2013-07-30 13:56:58 -07:00
Mathias Agopian c3a5225d4e Fix typos and use new HAL_PRIORITY_URGENT_DISPLAY constant
Change-Id: I703f8a96dd0dfec427e74363ad95729bfefc95c7
2013-07-30 13:56:57 -07:00
Glenn Kasten 6fbe0a86a8 Add C++ thread API androidGetThreadSchedulingGroup
This API is intended for applications that need to read a thread's
scheduling group, while using the higher-level (C++) family of thread APIs.

Change-Id: I5e58017f74c3989b20b5b1cc2bc4483c95720520
2013-07-30 13:56:57 -07:00
Glenn Kasten 6839e8e9ee Add Thread::join
This new API will be used by applications that previously used the
lower-level pthread APIs (including pthread_join).  Centralizing on the
Thread class instead of pthread will permit additional functionality to
be added later in only one location.

Change-Id: I8460169ac9c61ac9f85752405ed54c94651058d7
2013-07-30 13:56:57 -07:00
Glenn Kasten 5e0243f4d6 Thread ID zero for androidSetThreadSchedulingGroup
Already implemented by androidSetThreadPriority but not documented

Change-Id: I85302b17092952065f3f3a4214d8d8abdd465dbd
2013-07-30 13:56:57 -07:00
Glenn Kasten a538e268e6 Remove redundant memory barrier
pthread_create already includes the necessary memory barriers:
 - parent at pthread_create : pthread_mutex_unlock(start_mutex)
 - child at __thread_entry : pthread_mutex_lock(start_mutex)

Add lock around uses of mThread.

Added comments:
 - uses of mThread require lock
 - androidCreateRawThreadEtc returned ID is not safe for direct use from non-parent threads.

Change-Id: I18cb296b41ddaf64cf127b57aab31154319b5970
2013-07-30 13:56:57 -07:00
Glenn Kasten 966a48f3e7 Bug 3362814 Fix SMP race in access to mRequestExit
Also fix an unlikely SMP race in access to mHoldSelf on entry to _threadLoop.

Change-Id: I6cbc0b94739c7dd5e77e8a5ba0da22cdc0b1a4db
2013-07-30 13:56:55 -07:00
Mathias Agopian 9b0be73f2a added RWLock C++ wrapper
Change-Id: Ia736bf7f6e2c49915a9ab5669551cf89dafa7961
2013-07-30 13:56:53 -07:00
Mathias Agopian 68f6481820 libutils Condition are now PRIVATE by default
Condition must be initialized with SHARED for the old behavior, where
they can be used accross processes.

Updated the two places android that require SHARED conditions.

PRIVATE conditions (and mutexes) use more efficient syscalls.

Change-Id: I9a281a4b88206e92ac559c66554e886b9c62db3a
2013-07-30 13:56:53 -07:00
Dianne Hackborn 235af97deb Propagate background scheduling class across processes.
This is a very simply implementation: upon receiving an IPC, if the handling
thread is at a background priority (the driver will have taken care of
propagating this from the calling thread), then stick it in to the background
scheduling group.  Plus an API to turn this off for the process, which is
used by the system process.

This also pulls some of the code for managing scheduling classes out of
the Process JNI wrappers and in to some convenience methods in thread.h.
2013-07-30 13:56:52 -07:00
San Mehat f4d57661be process: Switch to common cutils sched_policy api
Signed-off-by: San Mehat <san@google.com>
2013-07-30 13:56:52 -07:00
San Mehat 7089ab8b38 Process: Add support for using scheduler policies instead of cgroups.
Preference is given to cgroups if available.

Signed-off-by: San Mehat <san@google.com>
2013-07-30 13:56:52 -07:00
Mathias Agopian 51ce3ad760 use broadcast() instead of signal() when signaling the condition-variable Thread::RequestExitAndWait() is waiting for
we could have several thread waiting on the condition and they all need to wake-up.
also added a debug "mTid" field in the class, which contains the tid of the thread (as opposed to pthread_t), this
is useful when debugging under gdb for instance.
2013-07-30 13:56:52 -07:00
Mathias Agopian de6926bc94 add a ctor to Mutex to specify the type, which can be shared. This is used by sf and af an soon will allow some optimization in the kernel for non shared mutexes 2013-07-30 13:56:51 -07:00
Mathias Agopian 1555436473 implement Mutex and Condition with pthread instead of calling futex directly.
internally pthread uses futex. the implementation consists of simple inlines
there are no implementation files anymore.
2013-07-30 13:56:51 -07:00
Mathias Agopian d0ef3d46f9 some work to try to reduce the code size of some native libraries
- make sure that all binder Bn classes define a ctor and dtor in their respective library.
  This avoids duplication of the ctor/dtor in libraries where these objects are instantiated.
  This is also cleaner, should we want these ctor/dtor to do something one day.

- same change as above for some Bp classes and various other non-binder classes

- moved the definition of CHECK_INTERFACE() in IInterface.h instead of having it everywhere.

- improved the CHECK_INTERFACE() macro so it calls a single method in Parcel, instead of inlining its code everywhere

- IBinder::getInterfaceDescriptor() now returns a "const String16&" instead of String16, which saves calls to String16 and ~String16

- implemented a cache for BpBinder::getInterfaceDescriptor(), since this does an IPC. HOWEVER, this method never seems to be called.
  The cache makes BpBinder bigger, so we need to figure out if we need this method at all.
2013-07-30 13:56:50 -07:00
San Mehat 624a35ee48 Add support for changing a threads scheduler group. Three groups are available (default, background non interactive, foreground boost). Setting a thread priority to PRIORITY_BACKGROUND will transparently change groups to background
Signed-off-by: San Mehat <san@google.com>
2013-07-30 13:56:49 -07:00
The Android Open Source Project 7a4c83922e auto import from //depot/cupcake/@136594 2013-07-30 13:56:49 -07:00
The Android Open Source Project cbb1011c95 auto import from //depot/cupcake/@135843 2013-07-30 13:56:49 -07:00
The Android Open Source Project cf59fa8dc7 auto import from //depot/cupcake/@135843 2013-07-30 13:56:49 -07:00
The Android Open Source Project d245d1d097 Initial Contribution 2013-07-30 13:56:46 -07:00