Deadlock or how to hang a process waiting for a resource indefinitely ☠☠☠

April 4, 2014 No comments

It’s a typical exercise, but we always see it theoretically, let’s bring it to practice. We’re developing with semaphores. As we can see here and here, semaphores, among other things will be used to block a process or thread …

Creating a mutex with semaphores between child processes in C [fork()]

March 19, 2014 No comments

We’ve been practicing sharing variables between child processes, but when there are some processes trying to access a shared resource, we need a mutex to make it safer. This time to implement the mutex we’ll use semaphores. This semaphores …

Shared variables between child processes in C [fork()]

March 5, 2014 No comments

Another way of facing concurrency in the wonderful world of doing several task at the same time is using child processes with fork(). The main difference between fork and threads is that forked process are full process, they have their …

Canceling and resume tasks with Timer and TimerTask in Java

February 5, 2014 No comments

We’ve been talking about using TimerTask and Timer to schedule tasks and passing arguments to these tasks for a more complex functionality. Today, we’ll be cancelling these periodic tasks (easy), but there are some problems when resuming, so I propose …

Concurrency, when several threads fight for the access to a resource [ example in C ]

January 30, 2014 No comments

If we’re creating a multi-thread application and we’re also sharing information between the main thread and the secondary thread, or between threads, you must have in mind the type of access to that information.
For example, if we will …

Passing arguments to a TimerTask in Java

January 17, 2014 No comments

I recently talked about using TimerTask in Java. Today we will pass variables or attributes to that TimerTask. We saw in the last article variable passing to an implicit or inner class, but now we’re creating a subclass and passing …

Concurrency, POSIX threads and shared variables in C

January 14, 2014 No comments

A few days ago, we talked about building our first multi-thread programs using POSIX threads. But soon a need arises: share data between the main thread and the recently launched thread, at least to indicate what we want it …

Non-blocking TCP client in C, where we can send and receive data at every moment

January 10, 2014 No comments

If you are creating a program which interacts with a server, this may interest you. First, we’re going to make a simple TCP client, we connect to a server and it will allow us to send whatever we write on …

Dinamically allocate memory for a bi-dimensional array in C

January 7, 2014 No comments

One of the biggest faults of an array is that we have to define it’s size in coding time. Sometimes it’s the easiest thing to do and it’s ok, we may waste some bytes (As in a little string when …

Introduction to Timer and TimerTask in Java

January 4, 2014 No comments

Timers are a useful tool to launch a task periodically, for example, if we are connected to a server, we can send status information to avoid disconnections, or launch a cron task, or even to run an animation (as the …

Top