The Programming Tutorial for Pcynlitx Platform

The document which is named as "Technical_Introduction.pdf" includes the same content and it can be downloaded as PDF from the link depicted as PDF Documents on the Documentation menu. In this tutorial, it has been assumed that the reader has basic knowledge about object oriented C++ programming. This tutorial documentation has been divided two pages.


Pcynlitx is an outcome of the scientific research study that is carried out by Erkam Murat Bozkurt and it has been developed based on a new idea. This idea is to develop a software that can write codes in a collaboration with its user. By this way, pcynlitx acts as a separate intelligent actor simplifying the multi-threaded software development process. Beside to this, it is a well known fact that the processing power of the computers will not increase dramatically in the next decades. This situation makes low level programming languages more popular ( C/C++, Ada etc ). On the contrary, to learn these languages is very difficult. The main purpose of this research study is to develop an easy and efficient way in order to decrease the complexity that are faced on the programming with low level languages such as C++. Basically, pcynlitx is just a partiular application of this new paradigm and it is an open source, free to use IDE which produces a class library for C++ multi-thread programming applications. The outcome of the pcynlitx acts as an autonomous management system for the thread synchronization tasks. Although the idea behind the pcynlitx platform is complex, the usage of the pcynlitx is very easy. In practice, pcynlitx platform produces a useful and compact library establishing a multi-thread programming framework based on your needs.


In multithreading, the biggest problem is non-deterministic schedulling of the threads. The execution order and the priority of the threads reflect the term of scheduling. More specifically, it is a decision about which thread will run and which thread will be suspended in a particular time interval. In practice, the operating system schedules the threads. On the contrary, on the applications in which pcynlitx platform are used, the programmer can directly schedule the threads.


Basically, pcynlitx is a code generator which can be programmed by the programmer. More specifically, It receives the requirements of the software to be developed from the programmer by means of a descriptor file and then, writes a C++ class library ( a thread library ). In practice, the programmers enter their preferences to the graphical user interface of the pcynlitx by means of some menus and pcynlitx builds the descriptor file automatically. In fact, pcynlitx collects information about the context of the program from its user and produce an application specific thread management library. Then, the programmer of the pcynlitx writes the program codes using a threading library which is specialized for a particular application. Thanks to its collective programming approach, pcynlitx platform establishes an autonomous thread management system organizing the execution of the threads according to its user directives. In order to learn why application specific library is necessary, please look the link which is given in below.

Why application specific library construction is necessary ?

3.1 What is meta-programming

Meta-programs are special type of programs that writes codes. In other words, they are the softwares that write codes. Actually, pcynlitx is a collection of several meta-program and a graphical user interface ( GUI) that controls the execution of these meta-programs. In pcynlitx platform, the programmers must develop the programs step by step and in each step, the pcynlitx gives some reports to the user. More specifically, in pcynlitx, the programs are developed by means of an interaction between the programmer and the pcynlitx. From a different point of view, we can easily say that the pcynlitx assists the programmer in the multi-thread application development.

3.2 What are the programmable meta programming systems ?

The term programmable meta programming system is used for the first time in the research paper about the pcynlitx project by Erkam Murat bozkurt who is the developer of the platform and it refers such a meta programming system that can be programmed by its user in order to produce an application-specific code library. In this system, the programmer enters a pice of information about the software to be developed to an intelligent integerated development environment (we can define this platform as a meta programming system or an intelligent entegrated development environment that can write complex software management codes ). Then, the user interface of the meta programming system fills a template file ( Descriptor File ) describing the specifications of the software to be developed. Then, the programmable meta programming system produces an applications specific library according to the recuirements of the software applications which will be developed.

3.3 Introduction to Descriptor File

In fact, pcynlitx is not a multi-threading library. Instead, it is a multi-threading library generator and in each library construction process, it produces a new "application specific multi-threading library" relaying on the programmer needs. The term "application specific multi-threading library" refers such a library that has some application specific properties. In other words, on the library, there are some special tools which are generated for a certain class or application. However, in order to achieve this, pcynlitx needs to improve its global knowledge about the software to be developed. Therefore, before the library construction process, pcynlitx collects information about the context of the program from the programmer by means of a descriptor file.


How pcynlitx collects information from its user

However, this communication brings some extra costs for the programmer. In order to differentiate each information from the others, some special syntax rules has to be followed by the programmer when information entered to the descriptor file. For descriptor file, the word “Description” is a key word and it indicates that the following code lines include descriptions about multi-threaded program. A sample description that is used on the declaration of the header file locations has been shown in below.

Fortunately, the pcynlitx users does not have to learn the coding syntax of the descriptor file. In contrast, the users enter their preferences by means of the graphical user interface and the descriptor file is coded automatically. Then, before the library construction process, the users can easily print their own preferences to the screen. On the other hand, if the descriptor file will be written by the programmer, the name of the descriptor file must be determined as "Project_Descriptor_File" in the file system. Different file names can not be recognized as descriptor file by the pcynlitx. In practice, descriptor files act as an interface between the programmer and pcynlitx. From a different perspective, descriptor file can be considered as a contract which is signed between the meta-program and the programmer before the library construction process. In brief, the programmer enters a list of information to the descriptor file and a meta-program reads that file.

3.4 How the code files are written by Pcynlitx

The classes are written based on the code templates which are defined on each meta-program as character lists which are in the form of separated code lines. In the code templates, some places recuire application specific information such as the number of the threads to be created or the return value of a member function. According to the information coming from the other units of the Pcynlitx such as Description Processing System and Class Declarations Readers, the places on the inside of these templates are filled by the meta-programs producing the code files and the final form of the code files are produced. A pseudo code illustrating how the code templates are used by the meta-programs of the Pcynlitx on the code writing processes has been given in below.The file construction processes are carried out as a sequence of the process and the same process is repeated until the code files of every class defined on the descriptor file will be written by the Pcynlitx.

3.4 The Benefits of the Application-Specific Library Production

In pcynlitx programming, the threads can be controlled by its unique number that is given by the programmer if the library that is provided by the pcynlitx is used. In fact, the user of the pcynlitx can directly schedule the execution of the threads independently from operating system. Moreover, the synchronization tools of the pcynlitx provides absolute deadlock protection if the program is written carefully. In addition, threading library that is constructed by the pcynlitx hides the most of the declarations that are actually performed on the development of a multi-threaded program by the programmer. Therefore, the pcynlitx reduces the syntax-complexity of C++ multi-thread programming.

3.5 Namespace Property of Pcynlitx

In pcynlitx the programmer can determine the namespace of the library to be constructed. The name "pcynlitx" is default namespace. If the namespace is not specified particulary by the programmer in descriptor file before library construction process, it is setted directly as the namespace of the library to be constructed. You can directly set the namepace of the library to be constructed by the meta-programming menu of the graphical user interface. For more information, please look the GUI tutorial.


In pcynlitx, the operations between the threads and the main thread are performed based on a client-server taxonomy. In this taxonomy, it is assumed that the main thread is the server of the variables to be shared between the threads and the threads to be created are the clients of the main thread. In fact, on the pcynlitx applications, only the addresses of some pre-defined objects and/or smart pointers can be shared between the threads. The reason of this restriction is the optimum memory usage and providing determinism. The parameter pass operations are performed by a special object that its type is written by the pcynlitx in library construction process. In fact, this object is a composition of the objects in which their addresses are shared between the threads. In pcynlitx applications, this object is named as the server object and the class which defines the type of the server object is named as server class as well. Not surprisingly, the name of the server object reflects its usage purpose and in pcynlitx applications, the server object is used as an object server. Strictly speaking, the server object passes the addresses of its own members to the threads automatically and it must be instantiated on the main function when it is used. In pcynlitx applications, the therm inter-thread object is an abbreviation that indicates the objects which are shared between the threads. In pcynlitx, if an object or a smart pointer will be shared between the threads, some informations of these classes such as the name of the classes, the paths of their header files and source files must be declared on the descriptor file. Then, a server object that manages not only thread creation but also parameter pass operations will be produces automatically by the pcynlitx. Default name of the server class is "Thread_Server" and it is determined by the pcynlitx. However, the user of the pcynlitx can also set the name of the server class. The basic structure of the pcynlitx applications is given in below.

In the figure which is given in above, it is seen that there is another server object's standard member which is named as "Manager Object". The "Thread_Manager" class is the type of the objects which are used in order to synchronize the threads and an instance of the Thread_Manager class ( Manager object ) is defined as a public member of the server class on the each library construction process automatically. On the following of the tutorial, the manager object will be explained. For now, we must concentrate the server object. It is obvious that an instance of each member of the server object is produced automatically when an instance of the server class is constructed on the main function. Then, each public member of the server object will be defined on the main function scope. It has been already mentioned that only the addresses of the inter-thread objects are shared between the threads. However, in the library construction process, some special classes in which their instances are used as a connection point to the inter-thread objects are defined automatically by the pcynlitx platform. In pcynlitx applications, these classes are named as client classes and their instances are named as client objects. The client classes are explained briefly in the following of this document.


In pcynlitx, many operation are performed by server object and thread creation is performed by the server object as well. The server class has a member function that creates the threads and this function is named as “Activate( )”. With the help of this member function, the threads can be created with their unique numbers that are given by the programmer. A sample thread creation is shown in the Figure that is depicted in below. The member function takes two arguments.

The activation of the threads on pcynlitx applications

In pcynlitx applications, the threads are controlled by means of their unique numbers which are assigned by the programmer to the threads. Hence, in the figure, the first argument is the number of the thread to be created and the second argument is the name of the thread function to be executed. The type of the first argument is integer and the type of the second argument is a function pointer that points the thread function routine. Simply,it is the name of the function routine which will be executed by the thread to be created.


Pcynlitx defines a data structure including the pointer members that point the inter-thread objects and smart pointers ( the objects which are shared between the threads ). This data structure is named as inter-thread data structure ( itds ). The server class includes an instance of that structure which its members point the inter-thread objects. It has been already indicated that the inter-thread objects are also the members of the server class. Therefore, with the help of the inter-thread data structure, the server object can pass the addresses of its own members to the threads. To be able to pass the unique numbers which are given by the user to the threads, in the the library construction process of the pcynlitx applications, a second data structure which is named as the thread specific data structure ( extit{ thds }) is defined automaticly. Thread specific data structure includes both thread number and a pointer that holds the address of the inter-thread data structure. This mechanism is shown in below figure.

If the address of the inter-thread data structure is passes to the threads, then, each inter-thread object will be reachable on the threads. But, it is still unclear that how the public member functions of these inter-thread objects can used on the address spaces of the threads. In the library construction process of the pcynlitx platform, a helper class which can be used as an indirection mechanism is produced automatically for each inter-thread class. In the previos sections, these classes are indicated named as the client classes. These special classes have a copy of each public member function of their corresponding inter-thread class and the indirection are performed automatically on the inside of these member functions. By this way, the programmer can call the public member functions of the inter-thread objects from the address spaces of the threads. In pcynlitx, the relation between an inter-thread object and its helper object can be considered as a “client-server” relation. Because, helper objects are just connection points to the inter-thread classes. Whenever a helper class’s member function is called, actually its parameters are passed to its corresponding inter-thread class. The client classes is named with the combination of the name of its inter-thread classes and "_Client" subfix.


The constructors of the client classes take the only argument of thread functions which is in fact the address of the thread specific data structure as their arguments. For example, let we assume that the name of the inter-thread class is "Mean_Value" and the name of its client is "Mean_Value_Client". The instance of the Mean_Value_Client can be constructed as in below.

Thanks to the descriptor file, the pcynlitx platform knows the type of the objects that are used on the threads. Therefore, the client classes are written with a private pointer that points its corresponding inter-thread class. Then, on the construction of the client objects, the addresses of their corresponding inter-thread objects are received by the client object by means of thread-specific data structure ( thds ). It has been already indicated that the client objects are used as a connection point to the inter-thread objects. With the help of the client objects, the programmer can make indirection to the public member functions of the inter-thread objects without using any pointer. In order to achieve this, the client classes are build in a special form. The structure of the client classes is shown in below figure.

The declaration of a client class includes an exact copy of each public member function of its counterpart ( the corresponding inter-thread class ) and a private pointer member that points the objects which are in the type of its counterpart. On the inside of the member functions of the client classes, an indirection is performed directly to an instance of its counterpart. In other words, if a member function of a client object is called, in fact, the corresponding member function of the inter-thread object is called by means of the client object’s pointer. A sample function call for the client objects is shown in below figure.

Next Page : Programming Tutorial Page - 2

Go to Next Page