Debian Codegraph @

src/core/scheduler.h

raw symbols SCIP
1 /*
2 *
3 * Ophcrack is a Lanmanager/NTLM hash cracker based on the faster time-memory
4 * trade-off using rainbow tables.
5 *
6 * Created with the help of: Maxime Mueller, Luca Wullschleger, Claude
7 * Hochreutiner, Andreas Huber and Etienne Dysli.
8 *
9 * Copyright (c) 2008 Philippe Oechslin, Cedric Tissieres, Bertrand Mesot
10 *
11 * Ophcrack is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * Ophcrack is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with Ophcrack; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 * This program is released under the GPL with the additional exemption
26 * that compiling, linking, and/or using OpenSSL is allowed.
27 *
28 *
29 *
30 *
31 */
32 #ifndef SCHEDULER_H
33 #define SCHEDULER_H
34
35 #define NQUEUES 3
36
37 #include <pthread.h>
38 #include <semaphore.h>
39
40 #include "misc.h"
41 #include "list.h"
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 typedef enum { low=0, disk, high } prty_t;
48
49 typedef struct scheduler_t_ {
50 int nthreads; /**< Number of threads. */
51 int ntasks; /**< Number of executable tasks pending. */
52 int pause;
53 int disk; /**< Indicates whether the disk is being
54 accessed by a thread */
55 list_t *queue[NQUEUES]; /**< The queues. */
56 sem_t *sem; /**< Semaphore for controlling the
57 access to the queues . */
58 pthread_cond_t *cond;
59 pthread_mutex_t *mutex; /**< Mutex for blocking the access to
60 the shared ressources. */
61 pthread_t *thread; /**< The threads. */
62 } scheduler_t;
63
64 scheduler_t *scheduler_alloc(int nthreads);
65 void scheduler_free(scheduler_t *sched);
66
67 /** Start the scheduler.
68 *
69 * Create the requested number of threads.
70 *
71 * @param sched A pointer to as scheduler structure.
72 * @param fun A pointer to the function to be exectued by the threads.
73 * @param arg A pointer to the arguments to be send to the threads.
74 * @return The number of threads successfully spawn. An error occured
75 * if this is less than the number of threads requested.
76 */
77
78 int scheduler_start(scheduler_t *sched, void *(*fun)(void*), void *arg);
79 void scheduler_pause(scheduler_t *sched);
80 void scheduler_continue(scheduler_t *sched);
81 void scheduler_wait(scheduler_t *sched);
82 void scheduler_stop(scheduler_t *sched);
83
84 void scheduler_add(scheduler_t *sched, void *data, prty_t prty);
85 void *scheduler_get(scheduler_t *sched, int id);
86 int scheduler_done(scheduler_t *sched, int id);
87
88 #ifdef __cplusplus
89 }
90 #endif
91 #endif