9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Alt structs declared static in acme's threads
@ 2007-07-26 16:06 david jeannot
  2007-07-26 16:13 ` erik quanstrom
  0 siblings, 1 reply; 2+ messages in thread
From: david jeannot @ 2007-07-26 16:06 UTC (permalink / raw)
  To: 9fans

Hi,

Is there a reason why some Alt structures in
acme and rio's threads are declared static?

/sys/src/cmd/acme/acme.c:363: 	static Alt alts[NKALT+1];
/sys/src/cmd/acme/acme.c:428: 	static Alt alts[NMALT+1];
/sys/src/cmd/acme/acme.c:719: 	static Alt alts[N+1];

Thanks, david.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] Alt structs declared static in acme's threads
  2007-07-26 16:06 [9fans] Alt structs declared static in acme's threads david jeannot
@ 2007-07-26 16:13 ` erik quanstrom
  0 siblings, 0 replies; 2+ messages in thread
From: erik quanstrom @ 2007-07-26 16:13 UTC (permalink / raw)
  To: 9fans

by using static, alts is on the heap and not on the stack.
plan 9 doesn't default to huge stacks, so this makes a difference.
also, alts is automatically zeroed because it's on the heap.

the only difference between

	void
	fu(void)
	{
		static Alt alts[NKALT+1];

		for(;;)
			;
	}

and
		
	static Alt alts[NKALT+1];

	void
	fu(void)
	{
		for(;;)
			;
	}

is that in the second example, alts is visible outside the function fu.

- erik


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-26 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26 16:06 [9fans] Alt structs declared static in acme's threads david jeannot
2007-07-26 16:13 ` erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).