author  wenzelm 
Mon, 19 Jan 2009 19:38:03 +0100  
changeset 29564  f8b933a62151 
parent 28554  a6065ce44984 
child 30612  cb6421b6a18f 
permissions  rwrr 
24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

1 
(* Title: Pure/MLSystems/multithreading.ML 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

2 
Author: Makarius 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

3 

28149  4 
Dummy implementation of multithreading setup. 
24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

5 
*) 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

6 

25704  7 
signature BASIC_MULTITHREADING = 
8 
sig 

9 
val NAMED_CRITICAL: string > (unit > 'a) > 'a 

10 
val CRITICAL: (unit > 'a) > 'a 

11 
end; 

12 

24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

13 
signature MULTITHREADING = 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

14 
sig 
25704  15 
include BASIC_MULTITHREADING 
24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

16 
val trace: int ref 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

17 
val tracing: int > (unit > string) > unit 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

18 
val available: bool 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

19 
val max_threads: int ref 
25775
90525e67ede7
added Multithreading.max_threads_value, which maps a value of 0 to number of CPUs;
wenzelm
parents:
25735
diff
changeset

20 
val max_threads_value: unit > int 
28554  21 
val enabled: unit > bool 
28149  22 
val no_interrupts: Thread.threadAttribute list 
28160  23 
val regular_interrupts: Thread.threadAttribute list 
24 
val with_attributes: Thread.threadAttribute list > 

25 
(Thread.threadAttribute list > 'a > 'b) > 'a > 'b 

24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

26 
val self_critical: unit > bool 
25704  27 
val serial: unit > int 
24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

28 
end; 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

29 

c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

30 
structure Multithreading: MULTITHREADING = 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

31 
struct 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

32 

25735  33 
(* options *) 
34 

24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

35 
val trace = ref (0: int); 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

36 
fun tracing _ _ = (); 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

37 

c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

38 
val available = false; 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

39 
val max_threads = ref (1: int); 
28460  40 
fun max_threads_value () = 1: int; 
28554  41 
fun enabled () = false; 
24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

42 

28187
4062882c7df3
proper values of no_interrupts, regular_interrupts;
wenzelm
parents:
28169
diff
changeset

43 
val no_interrupts = 
4062882c7df3
proper values of no_interrupts, regular_interrupts;
wenzelm
parents:
28169
diff
changeset

44 
[Thread.EnableBroadcastInterrupt false, Thread.InterruptState Thread.InterruptDefer]; 
4062882c7df3
proper values of no_interrupts, regular_interrupts;
wenzelm
parents:
28169
diff
changeset

45 

4062882c7df3
proper values of no_interrupts, regular_interrupts;
wenzelm
parents:
28169
diff
changeset

46 
val regular_interrupts = 
4062882c7df3
proper values of no_interrupts, regular_interrupts;
wenzelm
parents:
28169
diff
changeset

47 
[Thread.EnableBroadcastInterrupt true, Thread.InterruptState Thread.InterruptAsynchOnce]; 
28160  48 

49 
fun with_attributes _ f x = f [] x; 

28149  50 

25735  51 

52 
(* critical section *) 

53 

24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

54 
fun self_critical () = false; 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

55 
fun NAMED_CRITICAL _ e = e (); 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

56 
fun CRITICAL e = e (); 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

57 

25735  58 

59 
(* serial numbers *) 

60 

25704  61 
local val count = ref (0: int) 
62 
in fun serial () = (count := ! count + 1; ! count) end; 

63 

28123
53cd972d7db9
provide dummy thread structures, including proper Thread.getLocal/setLocal;
wenzelm
parents:
26082
diff
changeset

64 
end; 
53cd972d7db9
provide dummy thread structures, including proper Thread.getLocal/setLocal;
wenzelm
parents:
26082
diff
changeset

65 

53cd972d7db9
provide dummy thread structures, including proper Thread.getLocal/setLocal;
wenzelm
parents:
26082
diff
changeset

66 
structure BasicMultithreading: BASIC_MULTITHREADING = Multithreading; 
53cd972d7db9
provide dummy thread structures, including proper Thread.getLocal/setLocal;
wenzelm
parents:
26082
diff
changeset

67 
open BasicMultithreading; 