fix thread_dettach

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2167 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2008-03-26 14:41:45 +00:00
parent 5a88dc6333
commit f933b890f0
5 changed files with 34 additions and 8 deletions

View File

@ -1346,9 +1346,6 @@ InitVersion(void)
}
#define K ((Int) 1024)
void
Yap_InitWorkspace(int Heap, int Stack, int Trail, int max_table_size,
int n_workers, int sch_loop, int delay_load)

View File

@ -384,10 +384,16 @@ p_thread_destroy(void)
static Int
p_thread_detach(void)
{
if (pthread_detach(ThreadHandle[IntegerOfTerm(Deref(ARG1))].handle) < 0) {
Int tid = IntegerOfTerm(Deref(ARG1));
pthread_mutex_lock(&(ThreadHandle[tid].tlock));
if (pthread_detach(ThreadHandle[tid].handle) < 0) {
/* ERROR */
pthread_mutex_unlock(&(ThreadHandle[tid].tlock));
return FALSE;
}
ThreadHandle[tid].tdetach =
MkAtomTerm(AtomTrue);
pthread_mutex_unlock(&(ThreadHandle[tid].tlock));
return TRUE;
}

View File

@ -55,6 +55,8 @@ typedef struct FREEB {
struct FREEB *b_next_size;
} BlockHeader;
#define K ((Int) 1024)
#define MinBlockSize (sizeof(BlockHeader)+sizeof(YAP_SEG_SIZE))
#define MaxBlockSize 0xffffff
#define InUseFlag 0x80000000
@ -138,4 +140,3 @@ void Yap_add_memory_hole(ADDR, ADDR);
#define SCRATCH_START_SIZE (64*1024L)
#define SCRATCH_INC_SIZE (64*1024L)

View File

@ -31,8 +31,7 @@
dgraph_max_path/5,
dgraph_min_paths/3,
dgraph_isomorphic/4,
dgraph_path/3,
dgraph_connected_components]).
dgraph_path/3]).
:- reexport(library(rbtrees),
[rb_new/1 as dgraph_new]).

View File

@ -18,6 +18,7 @@
undgraph_neighbors/3,
undgraph_neighbours/3,
undgraph_complement/2,
undgraph_components/2,
dgraph_to_undgraph/2,
undgraph_min_tree/2]).
@ -58,6 +59,8 @@
:- use_module(library(rbtrees),
[ rb_delete/4,
rb_insert/4,
rb_in/3,
rb_partial_map/4
]).
@ -160,4 +163,24 @@ undgraph_max_tree(G, T) :-
wundgraph_max_tree(WG, WT, _),
wundgraph_to_undgraph(WT, T).
undgraph_components(Graph,[Map|Gs]) :-
pick_node(Graph,Node,Children,Graph1), !,
undgraph_new(Map0),
rb_insert(Map0, Node, Children, Map1),
expand_component(Children, Map1, Map, Graph1, NGraph),
undgraph_components(NGraph,Gs).
undgraph_components(_,[]).
expand_component([], Map, Map, Graph, Graph).
expand_component([C|Children], Map1, Map, Graph1, NGraph) :-
rb_delete(Graph1, C, Edges, Graph2), !,
rb_insert(Map1, C, Edges, Map2),
expand_component(Children, Map2, Map3, Graph2, Graph3),
expand_component(Edges, Map3, Map, Graph3, NGraph).
expand_component([C|Children], Map1, Map, Graph1, NGraph) :-
expand_component(Children, Map1, Map, Graph3, NGraph).
pick_node(Graph,Node,Children,Graph1) :-
rb_in(Node,Children,Graph), !,
rb_delete(Graph, Node, Graph1).