Semaphores are not used to exchange a large amount of data but they
provide synchronization among processes.
There are 3 (logical) types of semaphores:

  • Binary Semaphore: have a value of 0 or 1
  • Counting semaphore – has a value >= 0
  • Set of counting semaphores – one or more semaphores, each of which
    is a counting semaphore.

    There are 2 basic operations performed with semaphores:

  • Wait – waits until the semaphore is > 0, then decrements it.
  • Post – increments the semaphore, which wakes waiting processes.

    A semaphore is created by using the semget(). There were various that
    can be performed on the semaphore by using the functions like semop(),
    semctl() etc.

Brief Synopsis of :

  • semget(): It gets a semaphore set identifier
    #include <sys/types.h>
    #include <sys/ipc.h>
    #include <sys/sem.h>

    int semget(key_t key, int nsems, int semflg);

    This function returns the semaphore set identifier associated with the
    argument key. A new set of nsems semaphores is created if key has the
    value IPC_PRIVATE or if no existing semaphore set is associated to key
    and IPC_CREAT is asserted in semflg (i.e. semflg & IPC_CREAT isn’t

    The presence in semflg of the fields IPC_CREAT and IPC_EXCL plays the
    same role, with respect to the existence of the semaphore set, as the
    presence of O_CREAT and O_EXCL in the mode argument of the open(2)
    system call: i.e. the semget function fails if semflg asserts both
    IPC_CREAT and IPC_EXCL and a semaphore set already exists for key.

    Upon creation, the low-order 9 bits of the argument semflg define the
    access permissions (for owner, group and others) for the semaphore
    set. These bits have the same format, and the same meaning, as the
    mode argument in the open(2) or creat(2) system calls (though the
    execute permissions are not meaningful for semaphores, and write
    permissions mean permission to alter semaphore values).

  • semctl(): semaphore control operations

    #include <sys/types.h>
    #include <sys/ipc.h>
    #include <sys/sem.h>

    int semctl(int semid, int semnum, int cmd, …);

    semctl() performs the control operation specified by cmd on the
    semaphore set identified by semid, or on the semnum-th semaphore of
    that set. (The semaphores in a set are numbered starting at 0.)

    This function has three or four arguments, depending on cmd. When
    there are four, the fourth has the type union semun. The calling
    program must define this union as follows:
    union semun {
    int val;                            /* Value for SETVAL */
    struct semid_ds *buf;    /* Buffer for IPC_STAT, IPC_SET */
    unsigned short  *array;  /* Array for GETALL, SETALL */
    struct seminfo  *__buf;  /* Buffer for IPC_INFO (Linux specific) */

    The semid_ds data structure is defined in <sys/sem.h>.

Corduroy in depth

I am now over with the read task of the files. To allow the points
saved in .dxf to exported to Corduroy, write operation is to performed. I
have started working on the write operation.

I have made a simple function that performs the write operation, but it needs li
ttle modifications to allow it work efficiently. Moreover, I am going through th
e Corduroy files, got to know what is the concept being used when the line is draw
n and now looking for the circle.

Also I went through C++ to grab a little more about the concepts that were not m
uch clearer to me.

Beside this I read basics of corduroy−element mesh generation description file format
Basic syntax for corduroy is like this :


  • [Initialization]
    It defines parameters common to all generatorsand has the following syntax.
    start-node =expression
    start-element =expression
    constraint =name
    material =name

    The default start-node and start-element is one.

  • [generators]
    The generators section contains specifications for generating the elements and the associated nodes.The section has the following syntax.

Also done with the line, grid, quadrilateral-grid generator. Reading more about brick and triangular generator.

Little more about dxf

Working with dxf, till now I am done with implementation of certain entities and the layers too, handling almost all the properties of layers.

After doing this much of work I went to Sir, he told me the code such powerful that it can tell the total lines, circles etc drawing consists of. He also something related to point too but it just skipped from my mind, need to confirm the things again. Side by side working on the write of the dxf.

Also, today was the  Sapient’s aptitude test. I went there without any preparation that really bad on my part. But whatever it went good:)
It consisted of 4 sections
1) verbal ( antonyms, synonyms , passage related question)
2) quantitative
3) technical ( full of data structures and very little of basic concepts of programming)
4) logical reasoning

Next on 26 another company will be visiting for the recruitment process preparing for it and side by side continuing with the wonders of dxf.

Adding spices to dxfrwInterface

Gagan’s dxfrwInterface was capable just to read the line i.e it read the start and end points of the line. Jasvir has also used that library and implemented the circle. I cloned his repository and have added the other entities such as point, ellipse, arc. Now it is ready to read the five entities.
Polyline implementation is on the way.  It was able to read vertices x and y. But facing problems in reading bulge, , the start and end point and unable to locate the external points x and y.
Also, the user will work obviously on more than layer but till now I am unable to find some functionality implemented this way. Soon will get my hands on it. My target is to soon make these entities capable of reading and writing in corduroy.
Hoping for the best :)

Working with libdxfrw

Today when I reached TCC found everyone was sitting outside as there was function in the TCC hall. I was all ready to use the libdxf file as suggested by the Sir yesterday. I was set that by hook or crook I need to use and implement the things using dxflib today only!

Suddenly I was remembered of the Jasvir and Gagan’s mail. Jasvir and Gagan had done some of the work on dxf. I went to Gagan’s Repo, cloned and installed the things but it gave me an error. I called Gagan and he told one of the libraries libdxf 0.57 needs to be installed.

After that I asked Jasvir, he told that line and circle had been implemented. Disussed with Hitesh and planned to embed more of the entities like arc, ellipse, polyline etc. Only the file named implementation.cpp needs to changed.

After that there was a some test called SkillWill, just went for that and continued with my work:)

Line number 1296 trick

I was through with dxf file. I had read and was satisfied that I have understood the things. I learnt how to read the code and the code for each entity was at line number 1296.

Now the testing began! What I did was doing chose the co-ordinates randomly and saved it in .crd extension. It was all done to understand the work-flow of the things. After that converted into .flt but it gave ccw error, the error symbolized that the co-ordinates need to be clockwise direction. Corrected the things and it worked smoothly.

I also tried to implement the code for the boundary in Felt and was able to do that. Now thought to generate a triangular mesh and was done with that too.

The next thing was to run the .flt file in Qcad, converted the Felt file to dxf and that worked out in Qcad. After all this talked to Sir and discussed the things with him. He told there is no need to do lot of mess, simply use libdxf lib and you would be able to handle the things.

I feel very much lucky to do this project. Getting to learn new and newer things. All seems really interesting!

Seminar Day

Seminars are always scheduled to be held on Saturdays. Mostly todays Seminars consisted of GD-Re-entry tasks. The students who were to give presentation today were:

1) Satwant, she gave the presentation on solving the simultaneous equations using Skyling method. It was not upto the mark but she was given a chance to prove her again the coming Saturday.

2) Darshpreet, Jagmeet, Navdeep: Task was regarding FEM, They showed the wonderful video regarding FEM on you tube, They accomplished their tasks well. Along with FEM task, told about differential equations and are in GD for completing their task.

3) Balpreet, presented  whatever she has done till now related to the Civil coding for load balancing as well discussed the problems.

4) Sameer Pujani: Explained the working of his Syllabus management system using WordPress.

5) Gurjit Mehta gave presentation on Front-End Development, told that Front-End-Development is about giving life to a design, we can’t imagine a website without it, need to stay updated for latest technologies, JS is inconsistent but JQuery resolves cross platform problems, Geo Locations are very very important.
Also there was lot of discussion regarding the word Cascading in Css.

Date with dxf ;)

Today I decided to completely go through the dxf file. It was too huge with too many lines of code and was not sure from where to start and what to read. I thought to talk to Hitesh as he have wonderful of ways of learning the thinks. He told to break the lines of code, delete by line by line see the changing results. As if we draw line by hit and trail we need to find where the whole code can be stored for that particular entity.
The piece of code contained something like layer by, removed the whole layer by part and when I saw the result nothing was drawn.
Then I commented the things line by line enclosed within the layer by part. I also got to know how the thickness of line can be changed. It was approximately 2500 lines of code. I adopted a trick first saved the default file of qcad , then made wrote code for drawing different entities like line, circle and compared with the default file using the diff command.
I am done with the dxf work heading forward towards next step. I know the paths what to follow but do not know how to follow. Now confused whether to save the point in dxf then save in .crd and then covert to .flt or to to generate a mesh in .flt and again convert to dxf and show in qcad. Thinking to do experiments.