2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <exec/semaphores.h>
8 #include <intuition/intuition.h>
9 #include <graphics/gfx.h>
10 #include <utility/hooks.h>
12 #include <proto/exec.h>
13 #include <proto/dos.h>
14 #include <proto/intuition.h>
15 #include <proto/graphics.h>
17 #include <clib/alib_protos.h>
23 /****************************************************************************************/
25 struct IntuitionBase
*IntuitionBase
;
26 struct GfxBase
*GfxBase
;
28 static struct Screen
*scr
;
29 static struct Window
*win
;
30 static struct Task
*task1
, *task2
, *maintask
;
32 static struct SignalSemaphore sem
;
34 /****************************************************************************************/
36 static void Cleanup(char *msg
)
42 printf("semtorture: %s\n",msg
);
49 if (task1
) DeleteTask(task1
);
50 if (task2
) DeleteTask(task2
);
53 if (win
) CloseWindow(win
);
54 if (scr
) UnlockPubScreen(0,scr
);
56 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
57 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
62 /****************************************************************************************/
64 static void Init(void)
69 /****************************************************************************************/
71 static void OpenLibs(void)
73 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library",39)))
75 Cleanup("Can't open intuition.library V39!");
78 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library",39)))
80 Cleanup("Can't open graphics.library V39!");
85 /****************************************************************************************/
87 static void GetVisual(void)
89 if (!(scr
= LockPubScreen(0)))
91 Cleanup("Can't lock pub screen!");
95 /****************************************************************************************/
97 static void MakeWin(void)
99 if (!(win
= OpenWindowTags(0,WA_PubScreen
,(IPTR
)scr
,
103 WA_Height
,scr
->WBorTop
+ scr
->Font
->ta_YSize
+ 1,
104 WA_Title
,(IPTR
)"Press RETURN key to start!",
105 WA_SimpleRefresh
,TRUE
,
110 WA_IDCMP
,IDCMP_CLOSEWINDOW
|
115 Cleanup("Can't open window!");
118 ScreenToFront(win
->WScreen
);
122 /****************************************************************************************/
124 static void Task1(void)
126 int a
= 1, b
= 2, c
= 3;
130 ObtainSemaphore(&sem
);
134 ReleaseSemaphore(&sem
);
138 /****************************************************************************************/
140 static void Task2(void)
146 ObtainSemaphore(&sem
);
149 ReleaseSemaphore(&sem
);
153 /****************************************************************************************/
155 static void MakeTasks(void)
157 maintask
= FindTask(NULL
);
159 task1
= CreateTask("Task 1", 0, Task1
, 40000);
160 task2
= CreateTask("Task 2", 0, Task2
, 40000);
162 if (!task1
|| !task2
) Cleanup("Can't create tasks!");
166 /****************************************************************************************/
168 static void Action(void)
170 SetWindowTitles(win
, "Test started! Cannot be aborted!", (STRPTR
)~0);
175 /****************************************************************************************/
177 static void HandleAll(void)
179 struct IntuiMessage
*msg
;
185 WaitPort(win
->UserPort
);
186 while ((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
190 case IDCMP_CLOSEWINDOW
:
194 case IDCMP_REFRESHWINDOW
:
196 EndRefresh(win
,TRUE
);
199 case IDCMP_VANILLAKEY
:
200 if (msg
->Code
== 13) Action();
204 ReplyMsg((struct Message
*)msg
);
209 /****************************************************************************************/
222 /****************************************************************************************/
223 /****************************************************************************************/
224 /****************************************************************************************/
225 /****************************************************************************************/