BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / debugger / invalidate_on_exit / invalidate_on_exit.cpp
blobabcea1c2860492a6c4cb8c70ba8a546fbb147c4a
1 /*
2 * Copyright 2008, Michael Lotz, mmlr@mlotz.ch
3 * Distributed under the terms of the MIT License.
4 */
7 #include <debug.h>
9 #include <signal.h>
11 #include <kscheduler.h>
12 #include <smp.h>
15 static sem_id sRequestSem = -1;
18 static int32
19 invalidate_loop(void *data)
21 while (true) {
22 if (acquire_sem(sRequestSem) != B_OK)
23 break;
25 uint32 message[3];
26 message[0] = sizeof(message); // size
27 message[1] = 'KDLE'; // message code
28 message[2] = 0; // flags
30 // where "d:0:baron' stands for desktop x of user y which both
31 // currently are hardcoded and where '_PTL' is the port link code
32 write_port(find_port("d:0:baron"), '_PTL', &message, sizeof(message));
35 return 0;
39 static void
40 exit_debugger()
42 release_sem_etc(sRequestSem, 1, B_DO_NOT_RESCHEDULE);
46 static status_t
47 std_ops(int32 op, ...)
49 if (op == B_MODULE_INIT) {
50 sRequestSem = create_sem(0, "invalidate_loop_request");
51 if (sRequestSem < B_OK)
52 return sRequestSem;
54 thread_id thread = spawn_kernel_thread(&invalidate_loop,
55 "invalidate_loop", B_NORMAL_PRIORITY, NULL);
56 if (thread < B_OK)
57 return thread;
59 resume_thread(thread);
60 return B_OK;
61 } else if (op == B_MODULE_UNINIT) {
62 // deleting the sem will also cause the thread to exit
63 delete_sem(sRequestSem);
64 sRequestSem = -1;
65 return B_OK;
68 return B_BAD_VALUE;
72 static struct debugger_module_info sModuleInfo = {
74 "debugger/invalidate_on_exit/v1",
75 B_KEEP_LOADED,
76 &std_ops
79 NULL,
80 exit_debugger,
81 NULL,
82 NULL
85 module_info *modules[] = {
86 (module_info *)&sModuleInfo,
87 NULL