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

Side by Side Diff: src/trusted/service_runtime/thread_suspension_test.cc

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include "native_client/src/shared/platform/nacl_log.h" 7 #include "native_client/src/shared/platform/nacl_log.h"
8 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h" 8 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h"
9 #include "native_client/src/trusted/service_runtime/sel_ldr.h" 9 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
10 #include "native_client/src/trusted/service_runtime/thread_suspension.h" 10 #include "native_client/src/trusted/service_runtime/thread_suspension.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 struct NaClApp app; 108 struct NaClApp app;
109 ASSERT_EQ(NaClAppCtor(&app), 1); 109 ASSERT_EQ(NaClAppCtor(&app), 1);
110 110
111 struct NaClAppThread app_thread; 111 struct NaClAppThread app_thread;
112 AppThreadInitMinimal(&app_thread); 112 AppThreadInitMinimal(&app_thread);
113 113
114 struct ThreadArgs thread_args; 114 struct ThreadArgs thread_args;
115 thread_args.natp = NULL; 115 thread_args.natp = NULL;
116 thread_args.var = 0; 116 thread_args.var = 0;
117 thread_args.should_exit = false; 117 thread_args.should_exit = false;
118 ASSERT_EQ(NaClThreadCreateJoinable(&app_thread.thread, MutatorThread, 118 app_thread.host_thread_is_defined = 1;
119 ASSERT_EQ(NaClThreadCreateJoinable(&app_thread.host_thread, MutatorThread,
119 &thread_args, NACL_KERN_STACK_SIZE), 1); 120 &thread_args, NACL_KERN_STACK_SIZE), 1);
120 ASSERT_EQ(NaClAddThread(&app, &app_thread), 0); 121 ASSERT_EQ(NaClAddThread(&app, &app_thread), 0);
121 TrySuspendingMutatorThread(&app, &thread_args.var); 122 TrySuspendingMutatorThread(&app, &thread_args.var);
122 thread_args.should_exit = true; 123 thread_args.should_exit = true;
123 NaClThreadJoin(&app_thread.thread); 124 NaClThreadJoin(&app_thread.host_thread);
124 } 125 }
125 126
126 127
127 // The test below checks that we do not get a deadlock when using 128 // The test below checks that we do not get a deadlock when using
128 // NaClUntrustedThreadsSuspendAll() on threads that cross between 129 // NaClUntrustedThreadsSuspendAll() on threads that cross between
129 // untrusted and trusted code by invoking NaCl syscalls. 130 // untrusted and trusted code by invoking NaCl syscalls.
130 // 131 //
131 // This is a stress test. It is not guaranteed to find a problem, but 132 // This is a stress test. It is not guaranteed to find a problem, but
132 // it did reproduce the problem in the original buggy version of the 133 // it did reproduce the problem in the original buggy version of the
133 // code when Sleep() calls were inserted in suitable places. 134 // code when Sleep() calls were inserted in suitable places.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 struct NaClApp app; 166 struct NaClApp app;
166 ASSERT_EQ(NaClAppCtor(&app), 1); 167 ASSERT_EQ(NaClAppCtor(&app), 1);
167 168
168 struct NaClAppThread app_thread; 169 struct NaClAppThread app_thread;
169 AppThreadInitMinimal(&app_thread); 170 AppThreadInitMinimal(&app_thread);
170 171
171 struct ThreadArgs thread_args; 172 struct ThreadArgs thread_args;
172 thread_args.natp = &app_thread; 173 thread_args.natp = &app_thread;
173 thread_args.var = 0; 174 thread_args.var = 0;
174 thread_args.should_exit = false; 175 thread_args.should_exit = false;
175 ASSERT_EQ(NaClThreadCreateJoinable(&app_thread.thread, SyscallInvokerThread, 176 app_thread.host_thread_is_defined = 1;
177 ASSERT_EQ(NaClThreadCreateJoinable(&app_thread.host_thread,
178 SyscallInvokerThread,
176 &thread_args, NACL_KERN_STACK_SIZE), 1); 179 &thread_args, NACL_KERN_STACK_SIZE), 1);
177 ASSERT_EQ(NaClAddThread(&app, &app_thread), 0); 180 ASSERT_EQ(NaClAddThread(&app, &app_thread), 0);
178 TrySuspendingSyscallInvokerThread(&app, &thread_args.var); 181 TrySuspendingSyscallInvokerThread(&app, &thread_args.var);
179 thread_args.should_exit = true; 182 thread_args.should_exit = true;
180 NaClThreadJoin(&app_thread.thread); 183 NaClThreadJoin(&app_thread.host_thread);
181 } 184 }
182 185
183 #endif 186 #endif
OLDNEW
« no previous file with comments | « src/trusted/service_runtime/sel_ldr_standard.c ('k') | src/trusted/service_runtime/win/thread_suspension.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698