Click here to load reader

Using CCL with Pin: A Tutorial - Projects/Project 2 Resource · PDF fileUsing CCL with Pin: A Tutorial 1. Introduction The Construction and Composition Language (CCL) ... • The

  • View

  • Download

Embed Size (px)

Text of Using CCL with Pin: A Tutorial - Projects/Project 2 Resource · PDF fileUsing CCL with...

  • Draft - Not for Distribution

    2/11/2004 9:04 AM

    Using CCL with Pin: A Tutorial

    1. Introduction The Construction and Composition Language (CCL) provides a way of specifying components and their assemblies, checking static constraints defined by the CCL language, checking static constraints defined by analysis technologies (called reasoning frameworks), and for generating C code for the Pin component technology, and for generating analysis models for reasoning frameworks (called interpretation).

    1.1 Objectives of this tutorial The objective of this tutorial is to get you started using CCL to generate Pin assemblies. It is by no means a complete summary of the languagesuch a summary does not yet exist. However, the basic ideas are simple and can be showed by example. The examples provided also give an overview of how to use the CCL processor, and how to interact with the RTX SDK.

    1.2 Caveats and Limitations CCL is a work in progress. What you have installed and will be interacting with as numerous limitations. Nonetheless, despite its rather severe limitations in its current form, you will be able to use CCL to develop small applications, and to experiment with the Pin code generator. What CCL doesnt do you can fill in by hand, once you get familiar with the structure of Pin components. CCL can help with that, too: the generated code tends to be quite readable and even commented. It is convenient to distinguish between limitations in the CCL frontendthe part that does static analysis, and the CCL backendthe part that generates code. (There are actually several backends, one for each interpretation. But that is another story.) Frontend limitations:

    The processor does its best to catch static semantic errors and give sensible error messages. Occasionally, however, the frontend will get confused. A sure sign of confusion is an assert violation. If this happens to you, look for the first reported error and repair it. Please send any source files that produce assertion errors to [email protected]

    There are several semantic constraints that have not been implemented, including: o No checking on singleton instantiations of services. o No checking on optional versus mandatory source pins in assembly.

  • Draft-Not for Distribution

    2/11/2004 9:04 AM Page 2 of 2

    o It is possible to violate the prohibition on 1:N synchronous interaction topology by successively connecting a synchronous source pin to > 1 sink pin.

    Backend limitations:

    Hierarchical assembly is not yet supported. Arrays of any kind are not yet supported. Built-in string operations are not yet provided. Timed transitions are not yet supported.

    1.3 Organization of this tutorial This tutorial presents a series of six examples. The examples are found in the Pin distribution in CCL/Examples. Each example is presented in four parts:

    The Assembly: A description of the assemblywhat the example does, and why it is presented.

    Construction: How you build the assembly. Mostly, this is routine. The CCL: The specification source as found on disk. In future versions of this

    tutorial this will include discussion of language features and semantics. Exercises: Mostly this is not defined, but it will eventually be. Perhaps you have

    some ideas? The examples all have trivial functionality, but they will help you to get started.

    1.4 Typographical conventions In general, 10 pt courier font is used for CCL text; 10 pt bold courier is used for reserved words in CCL. 12 pt courier is used for text that you will enter in command windows. Italics are sometimes used for emphasis.

    Note: This indicates something worth keeping in mind. IMPORTANT: This is something you had probably should keep in mind. WARNING: This is something you really must pay attention to.

    1.5 Getting Ready. Install Pin and the RTX runtime environment, as described elsewhere. Then set the following environment variables, which are assumed in this tutorial (you may of course change the specifics):

    PINSRC=c:Program Files\Microsoft Visual Studio\MyProjects\

  • Draft-Not for Distribution

    2/11/2004 9:04 AM Page 3 of 3


    Also, add %CCLSRC%\CCLBack\Debug to your PATH environment variable

    2. A Simple I/O Assembly

    2.1 The Assembly Lets build something. The SimpleIO assembly is possibly the simplest assembly that can be built. In fact, you wont even develop a component in this example: we will use two environment-provided services, one to accept keyboard input from the external world, and one to put strings to a console device in the external world. Here is a graphical depiction of the SimpleIO assembly in the Pin visual language:


    KeyboardComponent::kb >>

    SimpleIO::simpleIO() (RTX::rtx)

    putKeyboard (produce string msg);

    putConsole (consume string msg);

    Note: We use the convention type-name::instance-name in the graphical notation; this convention has no counterpart in CCL.

    2.2 Construction To build a runtime implementation of this assembly, open a command window and do the following: > cd %CCLSRC%\Examples\Ex1 > ccl.exe -gn -BKeyboardComponent -BOutputComponent SimpleIO.ccl The meaning of the command line arguments:

  • Draft-Not for Distribution

    2/11/2004 9:04 AM Page 4 of 4

    -g: generate code for components and services, and for each deployed assembly generate a controller. (A controller can be thought of as the composite of a set of component and service instances in a generic container).

    -n: suppress warning messages that arise during the code generation process. -B: do not generate code for named component or service. SimpleIO.ccl: this is the name of the CCL specification being processed.

    Invoking this command in a command window should yield the following output: 0 syntax errors, 0 static errors, 0 warnings OutputComponent: Builtin Component or Service (skipping code generation) KeyboardComponent: Builtin Component or Service (skipping code generation) Press any key to continue Also, the following files will be found in the current working directory, (or the directory specified by the environment variable CCL_GENERATED_CODE_DIR if you started this tutorial following the instructions in 1. Introduction):

    common (folder) KeyboardComponent (folder) OutputComponent (folder) SimpleIO (folder) simpleIO.dsw (Visual Studio workspace)

    Only SimpleIO and simpleIO.dsw were generated as a result of the above command. Open simpleIO.dsw using Visual Visual C++ V6, and view the contents using the FileView tab of your workspace. You should see something like this:

  • Draft-Not for Distribution

    2/11/2004 9:04 AM Page 5 of 5

    Weve opened up the simpleIO.c file. This source file is the C implementation of the controller, or container, for the simpleIO assembly. From the Build menu, set the active configuration of the KeyboardComponent project to KeyboardComponent Win32 RTSS Release, and build it. Do the same for each of the other projects in the simpleIO workspace. To run this assembly you will need to start a few Pin services. Presumably, you have already installed RTX (if not, you will need to do so now). Launch the RTSS Task Manager from the VenturCom RTX menu. You should see this:

  • Draft-Not for Distribution

    2/11/2004 9:04 AM Page 6 of 6

    Now you must use Start Task to initialize Pin. Use Start Task twice:

    1. Browse to locate the ABB_IPC distribution, and within this distribution navigate to PinDirectoryServer\PinDirectoryServer___Win32_RTSS_Release, and run PinDirectoryServer.rtss as an RTSS process.

    2. Browse to IPC_LIB\IPC_LIB___Win32_RTSS_Release\IPC_LIB.rtdll. Instead of running this, you will register it as an RTDLL. IMPORTANT: You must select the Share Between Processes check box. This selection is not the default setting, and a failure to select it will result in runtime errors.

    The RTSS Task Manager should look like this:

    Now that Pin is officially started, you can run the application. You could also use the task manager to register components and run their assemblies. However, this can also be done programmatically. In your working directory you will find several .bat files, one corresponding to each example. Open simpleIO.bat in a text editor if you care to see what is being run. Otherwise, run simpleIO in a command shell (in the working directory), and arrange youre the your windows in a tidy way. This is what my screen looks like:

  • Draft-Not for Distribution

    2/11/2004 9:04 AM Page 7 of 7

    The green indicators show the RTDLLs that are currently loaded (in memory). You can also see that the simpleIO.rtss program is running (as is the Pin directory server). Now enter some strings in the keyboard console. These strings should be displayed on the output console. It isnt very pretty, but it works. There is only one thing left to doquit the application. Type RtxExit in the keyboard console. You should notice two things.

    1. The green indicators on the RTDLLs have switched to purple (or perhaps chartreuse). This indicates that these RTDLLs are registered, but they have been unloaded from memory.

    2. The Keyboard Console has disappeared, but the Output Console remains. This is unfortunate, but we wont bother to explain here why this relic of the application remains. You must exit the console yourself (with the x window button).

    So thats all there is to it. Now lets have a closer look at SimpleIO.ccl.

    2.3 The CCL Specification Here is

Search related