FAQ
Reviewers: rsc,

Message:
Hello rsc (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
runtime: hide the semaphore table from garbage collector

Please review this at http://codereview.appspot.com/6528043/

Affected files:
M src/pkg/runtime/sema.goc


Index: src/pkg/runtime/sema.goc
===================================================================
--- a/src/pkg/runtime/sema.goc
+++ b/src/pkg/runtime/sema.goc
@@ -43,11 +43,13 @@
// Prime to not correlate with any user patterns.
#define SEMTABLESZ 251

-static union
+union semtable
{
SemaRoot;
uint8 pad[CacheLineSize];
-} semtable[SEMTABLESZ];
+};
+#pragma dataflag 16 /* mark semtable as 'no pointers', hiding from garbage
collector */
+static union semtable semtable[SEMTABLESZ];

static SemaRoot*
semroot(uint32 *addr)
@@ -98,7 +100,7 @@
void
runtime·semacquire(uint32 volatile *addr)
{
- Sema s;
+ Sema s; // Needs to be allocated on stack, otherwise garbage collector
could deallocate it
SemaRoot *root;

// Easy case.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedSep 18, '12 at 5:37a
activeSep 18, '12 at 7:18p
posts6
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase