Skip to content

Commit 772b300

Browse files
committed
---
yaml --- r: 654 b: refs/heads/master c: 616b7af h: refs/heads/master v: v3
1 parent 84273ec commit 772b300

19 files changed

+183
-348
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 13d6f874316c9f69ab3a29f120ce410da2290a64
2+
refs/heads/master: 616b7afb724a32df41eebfaf95402d008c60b411

trunk/src/Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ BOOT_CMIS := $(BOOT_MLS:.ml=.cmi)
248248

249249
RUNTIME_CS := rt/sync/timer.cpp \
250250
rt/sync/sync.cpp \
251-
rt/sync/spin_lock.cpp \
252-
rt/sync/condition_variable.cpp \
251+
rt/sync/lock_and_signal.cpp \
253252
rt/rust.cpp \
254253
rt/rust_builtin.cpp \
255254
rt/rust_crate.cpp \
@@ -383,6 +382,9 @@ self: $(CFG_COMPILER)
383382
TASK_XFAILS := test/run-pass/task-comm-8.rs \
384383
test/run-pass/task-comm-10.rs \
385384
test/run-pass/task-comm-15.rs \
385+
test/run-pass/task-comm-12.rs \
386+
test/run-pass/task-comm-2.rs \
387+
test/run-pass/task-comm-9.rs \
386388
test/run-pass/task-life-0.rs \
387389
test/run-pass/alt-type-simple.rs \
388390
test/run-pass/many.rs
@@ -936,3 +938,11 @@ clean:
936938
$(CFG_QUIET)rm -Rf $(PKG_NAME)-*.tar.gz dist
937939
$(CFG_QUIET)rm -f $(foreach ext,cmx cmi cmo cma o a d exe,\
938940
$(wildcard boot/*/*.$(ext) boot/*/*/*.$(ext)))
941+
942+
943+
# Local Variables:
944+
# mode: makefile-gmake
945+
# fill-column: 78;
946+
# buffer-file-coding-system: utf-8-unix
947+
# compile-command: "make -k 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
948+
# End:

trunk/src/rt/memory_region.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef MEMORY_REGION_H
1010
#define MEMORY_REGION_H
1111

12-
#include "sync/spin_lock.h"
12+
#include "sync/lock_and_signal.h"
1313

1414
class rust_srv;
1515

@@ -20,7 +20,7 @@ class memory_region {
2020
size_t _live_allocations;
2121
array_list<void *> _allocation_list;
2222
const bool _synchronized;
23-
spin_lock _lock;
23+
lock_and_signal _lock;
2424
public:
2525
enum memory_region_type {
2626
LOCAL = 0x1, SYNCHRONIZED = 0x2
@@ -42,4 +42,15 @@ inline void *operator new(size_t size, memory_region *region) {
4242
return region->malloc(size);
4343
}
4444

45+
//
46+
// Local Variables:
47+
// mode: C++
48+
// fill-column: 78;
49+
// indent-tabs-mode: nil
50+
// c-basic-offset: 4
51+
// buffer-file-coding-system: utf-8-unix
52+
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
53+
// End:
54+
//
55+
4556
#endif /* MEMORY_REGION_H */

trunk/src/rt/rust_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extern "C" {
4242
#include "util/hash_map.h"
4343
#include "sync/sync.h"
4444
#include "sync/timer.h"
45-
#include "sync/condition_variable.h"
45+
#include "sync/lock_and_signal.h"
4646
#include "sync/lock_free_queue.h"
4747

4848
class rust_dom;

trunk/src/rt/rust_kernel.cpp

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ rust_kernel::rust_kernel(rust_srv *srv) :
1212

1313
rust_handle<rust_dom> *
1414
rust_kernel::create_domain(const rust_crate *crate, const char *name) {
15-
LOCK(_kernel_lock);
15+
_kernel_lock.lock();
1616
rust_message_queue *message_queue =
1717
new (this) rust_message_queue(_srv, this);
1818
rust_srv *srv = _srv->clone();
@@ -22,21 +22,23 @@ rust_kernel::create_domain(const rust_crate *crate, const char *name) {
2222
message_queue->associate(handle);
2323
domains.append(dom);
2424
message_queues.append(message_queue);
25-
UNLOCK(_kernel_lock);
25+
_kernel_lock.unlock();
26+
_kernel_lock.signal();
2627
return handle;
2728
}
2829

2930
void
3031
rust_kernel::destroy_domain(rust_dom *dom) {
31-
LOCK(_kernel_lock);
32+
_kernel_lock.lock();
3233
log(rust_log::KERN, "deleting domain: " PTR ", index: %d, domains %d",
3334
dom, dom->list_index, domains.length());
3435
domains.remove(dom);
3536
dom->message_queue->disassociate();
3637
rust_srv *srv = dom->srv;
3738
delete dom;
3839
delete srv;
39-
UNLOCK(_kernel_lock);
40+
_kernel_lock.unlock();
41+
_kernel_lock.signal();
4042
}
4143

4244
rust_handle<rust_dom> *
@@ -52,29 +54,29 @@ rust_kernel::internal_get_dom_handle(rust_dom *dom) {
5254

5355
rust_handle<rust_dom> *
5456
rust_kernel::get_dom_handle(rust_dom *dom) {
55-
LOCK(_kernel_lock);
57+
_kernel_lock.lock();
5658
rust_handle<rust_dom> *handle = internal_get_dom_handle(dom);
57-
UNLOCK(_kernel_lock);
59+
_kernel_lock.unlock();
5860
return handle;
5961
}
6062

6163
rust_handle<rust_task> *
6264
rust_kernel::get_task_handle(rust_task *task) {
63-
LOCK(_kernel_lock);
65+
_kernel_lock.lock();
6466
rust_handle<rust_task> *handle = NULL;
6567
if (_task_handles.get(task, &handle) == false) {
6668
handle =
6769
new (this) rust_handle<rust_task>(this, task->dom->message_queue,
6870
task);
6971
_task_handles.put(task, handle);
7072
}
71-
UNLOCK(_kernel_lock);
73+
_kernel_lock.unlock();
7274
return handle;
7375
}
7476

7577
rust_handle<rust_port> *
7678
rust_kernel::get_port_handle(rust_port *port) {
77-
PLOCK(_kernel_lock);
79+
_kernel_lock.lock();
7880
rust_handle<rust_port> *handle = NULL;
7981
if (_port_handles.get(port, &handle) == false) {
8082
handle =
@@ -83,7 +85,7 @@ rust_kernel::get_port_handle(rust_port *port) {
8385
port);
8486
_port_handles.put(port, handle);
8587
}
86-
PUNLOCK(_kernel_lock);
88+
_kernel_lock.unlock();
8789
return handle;
8890
}
8991

@@ -126,7 +128,6 @@ rust_kernel::log(uint32_t type_bits, char const *fmt, ...) {
126128

127129
void
128130
rust_kernel::pump_message_queues() {
129-
LOCK(_kernel_lock);
130131
for (size_t i = 0; i < message_queues.length(); i++) {
131132
rust_message_queue *queue = message_queues[i];
132133
if (queue->is_associated() == false) {
@@ -137,27 +138,16 @@ rust_kernel::pump_message_queues() {
137138
}
138139
}
139140
}
140-
UNLOCK(_kernel_lock);
141141
}
142142

143143
void
144144
rust_kernel::start_kernel_loop() {
145+
_kernel_lock.lock();
145146
while (_interrupt_kernel_loop == false) {
147+
_kernel_lock.wait();
146148
pump_message_queues();
147-
148-
// FIXME: this is a complete hack to make the testsuite finish in a
149-
// sane time when executing under valgrind. The whole message-loop
150-
// system here needs replacement with an OS-level event-queue such
151-
// that actually wait on inter-thread notices, rather than
152-
// busy-waiting.
153-
154-
size_t ms = TIME_SLICE_IN_MS;
155-
#if defined(__WIN32__)
156-
Sleep(ms);
157-
#else
158-
usleep(ms * 1000);
159-
#endif
160149
}
150+
_kernel_lock.unlock();
161151
}
162152

163153
void
@@ -171,6 +161,7 @@ void
171161
rust_kernel::terminate_kernel_loop() {
172162
log(rust_log::KERN, "terminating kernel loop");
173163
_interrupt_kernel_loop = true;
164+
_kernel_lock.signal();
174165
join();
175166
}
176167

trunk/src/rt/rust_kernel.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ rust_handle :
3232
}
3333
};
3434

35-
#define LOCK(x) x.lock();
36-
#define UNLOCK(x) x.unlock();
37-
38-
#define PLOCK(x) printf("LOCKING @ %d\n", __LINE__); x.lock();
39-
#define PUNLOCK(x) x.unlock(); printf("UNLOCKED @ %d\n", __LINE__);
40-
4135
/**
4236
* A global object shared by all thread domains. Most of the data structures
4337
* in this class are synchronized since they are accessed from multiple
@@ -59,9 +53,9 @@ class rust_kernel : public rust_thread {
5953

6054
void run();
6155
void start_kernel_loop();
62-
bool volatile _interrupt_kernel_loop;
56+
bool _interrupt_kernel_loop;
6357

64-
spin_lock _kernel_lock;
58+
lock_and_signal _kernel_lock;
6559

6660
void terminate_kernel_loop();
6761
void pump_message_queues();

trunk/src/rt/rust_log.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
#include "rust_internal.h"
7-
#include "sync/spin_lock.h"
87
#include "util/array_list.h"
98
#include <stdarg.h>
109

@@ -64,7 +63,7 @@ static const char * _foreground_colors[] = { "[37m",
6463
/**
6564
* Synchronizes access to the underlying logging mechanism.
6665
*/
67-
static spin_lock _log_lock;
66+
static lock_and_signal _log_lock;
6867
static uint32_t _last_thread_id;
6968

7069
rust_log::rust_log(rust_srv *srv, rust_dom *dom) :

trunk/src/rt/sync/condition_variable.cpp

Lines changed: 0 additions & 84 deletions
This file was deleted.

trunk/src/rt/sync/condition_variable.h

Lines changed: 0 additions & 20 deletions
This file was deleted.

trunk/src/rt/sync/fair_ticket_lock.cpp

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)