c++ - Output for simple program using pthread -


void cleanuphandler(void *arg) {      printf("in cleanup handler\n"); } void *thread(void *string) {      int i;     int o_state;     int o_type;     pthread_cleanup_push(cleanuphandler, null);     pthread_setcancelstate(pthread_cancel_disable, &o_state);     pthread_setcanceltype(pthread_cancel_asynchronous, &o_type);     puts("1 hello world");     pthread_setcancelstate(o_state, &o_state);     puts("2 hello world");     pthread_cleanup_pop(0);     pthread_exit(null); } int main() {      pthread_t th;     int rc;     rc = pthread_create(&th, null, thread, null);     pthread_cancel(th);     pthread_exit(null); } 

i wondering output of code , in order happen. yes, practice test question exam have in 6 hours. appreciated. there no office hours today of ta's college busy own finals.

thanks

here man pages need understand problem putting on exam (which won't exact problem above.) need understand each of functions does.

in question (and presumably similar 1 on exam), need enumerate possible interleavings of calls these functions between 2 threads.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -