Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: src/trusted/service_runtime/nacl_app_thread.h

Issue 11543028: Allow creating a NaClAppThread without creating a new host OS thread (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Review: Add NACL_WUR Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/trusted/service_runtime/nacl_app_thread.h
diff --git a/src/trusted/service_runtime/nacl_app_thread.h b/src/trusted/service_runtime/nacl_app_thread.h
index d2b6f1ab91dd3f7e3c82e56ca6236f629fc3b794..e13c16273047fee401d2e9c600c9cc3f5e6eee53 100644
--- a/src/trusted/service_runtime/nacl_app_thread.h
+++ b/src/trusted/service_runtime/nacl_app_thread.h
@@ -71,7 +71,17 @@ struct NaClAppThread {
int thread_num; /* index into nap->threads */
- struct NaClThread thread; /* low level thread representation */
+ /*
+ * If host_thread_is_defined is true, host_thread is initialized and
+ * owned by the NaClAppThread such that it will be freed by
+ * NaClAppThreadDelete().
+ *
+ * host_thread_is_defined may be false when running untrusted code
+ * on a borrowed host thread that was not created by
+ * NaClAppThreadSpawn().
+ */
+ int host_thread_is_defined;
+ struct NaClThread host_thread; /* low level thread representation */
struct NaClMutex suspend_mu;
Atomic32 suspend_state; /* enum NaClSuspendState */
@@ -141,15 +151,17 @@ struct NaClAppThread {
int dynamic_delete_generation;
};
+void WINAPI NaClAppThreadLauncher(void *state);
+
void NaClAppThreadTeardown(struct NaClAppThread *natp);
/*
- * Low level initialization of thread, with validated values. The
- * usr_entry and usr_stack_ptr values are directly used to initialize the
- * user register values; the sys_tls_base is the system address for
- * allocating a %gs thread descriptor block base. The caller is
- * responsible for error checking: usr_entry is a valid entry point (0
- * mod N) and sys_tls_base is in the NaClApp's address space.
+ * NaClAppThreadMake() creates a NaClAppThread object without invoking
+ * untrusted code or creating a host thread.
+ *
+ * The usr_entry and usr_stack_ptr values are directly used to
+ * initialize the user register values. The caller is responsible for
+ * error checking: usr_entry must be a valid entry point (0 mod N).
*/
struct NaClAppThread *NaClAppThreadMake(struct NaClApp *nap,
uintptr_t usr_entry,
@@ -157,6 +169,17 @@ struct NaClAppThread *NaClAppThreadMake(struct NaClApp *nap,
uint32_t user_tls1,
uint32_t user_tls2) NACL_WUR;
+/*
+ * NaClAppThreadSpawn() creates a NaClAppThread and launches a host
+ * thread that invokes the given entry point in untrusted code. This
+ * returns true on success, false on failure.
+ */
+int NaClAppThreadSpawn(struct NaClApp *nap,
+ uintptr_t usr_entry,
+ uintptr_t usr_stack_ptr,
+ uint32_t user_tls1,
+ uint32_t user_tls2) NACL_WUR;
+
void NaClAppThreadDelete(struct NaClAppThread *natp);
/*
« no previous file with comments | « src/trusted/service_runtime/linux/thread_suspension.c ('k') | src/trusted/service_runtime/nacl_app_thread.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698