Course Hero Logo

sthreads.h - #ifndef STHREADS_H #define STHREADS_H /* On...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 2 out of 2 pages.

#ifndef STHREADS_H#define STHREADS_H/* On Mac OS (aka OS X) the ucontext.h functions are deprecated and requires thefollowing define.*/#define _XOPEN_SOURCE 700/* On Mac OS when compiling with gcc (clang) the -Wno-deprecated-declarationsflag must also be used to suppress compiler warnings.*/#include <ucontext.h>/* A thread can be in one of the following states. */typedef enum {running, ready, waiting, terminated} state_t;/* Thread ID. */typedef int tid_t;typedef struct thread thread_t;/* Data to manage a single thread should be kept in this structure. Here are a fewsuggestions of data you may want in this structure but you may change this toyour own liking.*/struct thread {tid_t tid;state_t state;ucontext_t ctx;thread_t *next; /* can use this to create a linked list of threads */};/*******************************************************************************Simple Threads APIYou may add or change arguments to the functions in the API. You may also addnew functions to the API.********************************************************************************//* InitializationInitialization of global thread management data structures. A user programmust call this function exactly once before calling any other functions inthe Simple Threads API.

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 2 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
miss ayesha
Tags
Subroutine, OpenMP

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture