Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!steinmetz!mizar!jesup From: jesup@mizar.steinmetz (Randell Jesup) Newsgroups: comp.sys.amiga Subject: Re: Comments on the uniqueness of task & window id's Message-ID: <6792@steinmetz.steinmetz.UUCP> Date: Thu, 23-Jul-87 17:07:17 EDT Article-I.D.: steinmet.6792 Posted: Thu Jul 23 17:07:17 1987 Date-Received: Sat, 25-Jul-87 08:35:51 EDT References: <8706260543.AA20346@cogsci.berkeley.edu> <4445@ihlpa.ATT.COM> <6752@steinmetz.steinmetz.UUCP> <198@dana.UUCP> Sender: root@steinmetz.steinmetz.UUCP Reply-To: jesup@sungod.steinmetz.UUCP (Randell Jesup) Organization: General Electric CRD, Schenectady, NY Lines: 73 Keywords: ID-handler In article <198@dana.UUCP> rap@dana.UUCP (Rob Peck) writes: >I encountered a problem that couldnt be solved with Forbid(), Permit() and >FindPort(). In particular, I created a master program, that called >test(). test() is something that runs a graphics demo of some kind; >it creates a window of a fixed size, and puts it on a custom screen >whose address it locates by issuing FindPort(myscreen). An addendum >to the port structure itself is the address of the custom screen. > >The master program NOW does: > > Disable(); > port = FindPort(myscreen); > if(port == 0) > /* .... create the port if not there ... */ > /* open a custom screen, put the address of > * custom screen into addendum to the port; > * set users_of_screen = 1 > */ > Enable(); > test(); > ... users_of_screen = users_of_screen -1; > > (another addendum to the custom port) > > if(users_of_screen = 0) CloseScreen(myscreen); ... >Rob Peck. ...ihnp4!hplabs!dana!rap How about this: (By the way, how is your port associated with you Screen???) main() { ... Forbid(); if (port = FindPort(myportname)) { } else { /* you might not want to forbid that long, so you might want to set users to 0 until the screen opened, and have somewthing that finds the port busy wait on the Screen variable. A bit bizarre, and I think it's ok to open a screen inside a Forbid(). */ } Permit(); Test(); ... Forbid(); if ( = 1) { CloseScreen(); RemPort(myportname); } else --; Permit(); ... } Actually, if I wanted to bother learning how they work I'm sure that semaphores would make this easier. Most problems I've dealt with using Forbid and Permit were coming up with unique ports, for example for a shell that has a port for receiving messages from sub-processes. I just Forbid, and then look for Shell_port_1. If it's there, I look for shell_port_2, etc. When I've found an unused port, I create it, then Permit. Randell Jesup jesup@ge-crd.arpa jesup@steinmetz.uucp (uunet!steinmetz!jesup)