Local worker
This commit is contained in:
parent
4219ae2888
commit
2924428bdf
|
@ -23,4 +23,21 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
pthread_t *WorkerInit(SchedulerParams_t *parameters);
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler destructor function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline int WorkerDestroy(pthread_t *schedThread)
|
||||
{
|
||||
free(schedThread);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler wait function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static inline void WorkerWait(pthread_t *schedThread)
|
||||
{
|
||||
pthread_join(*schedThread, NULL);
|
||||
}
|
||||
|
|
|
@ -18,3 +18,38 @@
|
|||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../include/base.h"
|
||||
|
||||
static void *LittleWorker(void *parameters);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler init function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
pthread_t *WorkerInit(SchedulerParams_t *parameters)
|
||||
{
|
||||
parameters->id = (pthread_t*) malloc(sizeof(pthread_t));
|
||||
pthread_create(parameters->id, NULL, LittleWorker, parameters);
|
||||
return parameters->id;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler thread main function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static void *LittleWorker(void *params)
|
||||
{
|
||||
SchedulerParams_t *parameters = (SchedulerParams_t*) params;
|
||||
int a = 4;
|
||||
|
||||
|
||||
for (int i = 0; i < 45000; i++) {
|
||||
for (int j = i; j < 45000; j++) {
|
||||
a = (a + (long)parameters->id) * i * j;
|
||||
}
|
||||
}
|
||||
|
||||
printf("thread %d\n", a);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue