Developers Club geek daily blog

Emulation of EEPROM for microcontrollers from the built-in flash memory

1 year, 9 months ago
In the built-in devices there are two main types of long-term memory: EEPROM (Electrically Erasable Programmable Read-only Memory) and flash (NAND/NOR).

EEPROM — electrically the erased reprogrammable read-only memory which allows to write and rewrite data just as it occurs for normal disk storage modules. Flash is kind of EEPROM and is characterized by that record is made by blocks, and removal is carried out page-by-page. It is impossible to rewrite storage cell in arbitrary value on Flash. Memory like EEPROM usually allows to rewrite bigger number of times in comparison with Flash, but record on Flash is carried out for shorter time. In favor of Flash it is possible to add that this type of memory is cheaper in production, in comparison with EEPROM therefore devices in which EEPROM and (much relatively) memory Flash there is not enough at the moment prevail.

Read more »


As cross-platform Half-Life or was created by "by Hedkraby in your hours"

1 year, 9 months ago


The couple of months back on Giktaymsa was slipped by news about the started Half-Life on Android Wear. In article words it has not been told about developers and then one of habrovchan has asked in comments why none of them will not write here?

And here anniversary since that moment as I have begun port of the free Xash3D engine on Linux, and also as some my acquaintances nevertheless were interested in details, I have decided to write this post. To whom the project history, bypasses of different problems and my personal councils is interesting, I ask under kat.

Read more »


Hallo! It is FreeSWITCH? Then we will check you

1 year, 9 months ago

At requests of our readers for check by means of PVS-Studio the project open source of FreeSWITCH has been taken. Originally it has been based by developers of the project, Asterisk which we already checked. The FreeSWITCH project is actively developed and contains many interesting warnings of the analyzer which will be described in article.

Read more »


mysqldump patch in house conditions

1 year, 9 months ago
image
Backups it is good, and it is even better when they work as it is necessary when they are necessary. On one of projects it was required to recover dump from 745 triggers and to roll them on working MySQL base.

MySQL allows to use any names of triggers, including with use of points (for example: analitica.cron.indeg.y.run.a_insert). And mysqldump at creation of dump does not consider this circumstance and adds construction for their track of the following look:

/*!50032 DROP TRIGGER IF EXISTS analitica.cron.indeg.y.run.a_insert */;

The dirty trick expects these dump in attempt to roll on base where these triggers are already created. From the point of view of MySQL this request does not dropnt the trigger because will not find the trigger with such name. For correct work the name of the trigger has to be put into apostrophes.

Read more »


We write the driver of the user environment for uinput on Raspberry Pi

1 year, 10 months ago
Фотография дисплеяFor the sake of one of the small projects on Raspberry Pi 2 I have got capacity the touch Waveshare display with the democratic price, modest permission and doubtful support. In box with the display DVD-R DL lay, and according to statements of the seller, images of systems on the basis of Raspbian lay there. I did not manage to read them, search of solutions on the Internet has prompted that the driver which lay there, was and so not the best solution (already compiled kernel without source codes).

In the course of search I have come across the project of one guy from friendly China. Thanks to it I could come to the decision.

Read more »


Use of handle and intrusive reference of counter-in multithreaded environments in language C

1 year, 10 months ago
Access to ody and same data in several flows is considered bad practice, but in many cases it is inevitable, and it not that question which is discussed here. Question which is discussed here, it how to organize such access in the safest way. Also here atomic operations which are mentioned here are not discussed: different compilers offer different means for such operations.

In the multithreaded environment when using object or data structure, one of the main issues, in addition, is guarantee of that the object to which is made access is still live also the memory selected for structure is not released.

It can be made in several ways, but we will speak only about two of them: hendla (handles) and built-in counters of links (intrusive reference counters).

Read more »


Sorting of integral numbers at memory contention

1 year, 10 months ago
The author of the original in English — habrayuzer of dzeban

Introduction


Last time we have discussed as it is possible to limit memory available to the program artificially. As bonus I have caught to myself libmemrestrict – library with wrappers of functions like malloc for memory use tracking, and ptrace-restrict — the tool on the basis of ptrace intercepting calls of brk, sbrk and mmap with the same purpose.

So why to us to try to organize memory restriction – whether so it often meets? When last time OOM has beaten your application? You always think of consumption of memory during programming? Memory – piece cheap and if you do not have enough memory, add couple more of gigabytes.

And, nevertheless, it is impossible to add infinitely memory – and not because you have no its infinite source. When processing Big data it is simply impossible to contain all input in array – it is necessary to distribute data between RAM, carriers and network. Algorithms and equipment for such data handling are necessary.

And here I was engaged in similar tasks, having begun about idle time – how to sort one million integral numbers (4 MiB of data) in the presence of 2 MiB of memory? This task can be generalized if you have not enough memory to contain all data.

It is given


It is necessary to write the sorting routine of set of the integral numbers which are stored in the file. For its creation I have written the simplest utilities of randints and rangeints

The program has to give out the sorted array on stdout in the form of the text

It has to measure operating time and bring it to stderr. It is impossible to start simply the program through the utility of time because she will count time for reading the file and time for its output.

It has to work, having memories at least is twice less than file volume. For this purpose we will apply libmemrestrict or ptrace-restrict.

These utilities will not be useful for some methods. For example, for mmap they will not work – it is necessary to limit memory use physically.

They will be checked for solution of original task (sorting of 4 MiB in 2 MiB). Also I will start them on virtualka from 128 MiB of memory for sorting of 500 Mb (125 million four-byte whole).

Read more »


Public Text Chat Server

1 year, 10 months ago
image
This article will be interesting to the people who are interested in networks, the logic device of servers and native programming. There will be no long listings of source codes, but only the general sketches and approaches.
TL; DR GitHub

It as imidzhborzh only the text

Same text, as well as on bigger measure this post.
Returning to the children's dream, I wanted to make text chat. For me it as one of options to increase quantity of missing api in library since only in such way you understand on the present that is necessary for the programmer when you write something more or less applied.

Read more »


Restriction of the memory available to the program

1 year, 10 months ago
I decided to be engaged somehow in a problem of sorting of one million integral numbers at the available memory in 1 MB. But before it I had to think how it is possible to limit the amount of available memory for the program. And here what I thought up.

Virtual memory of process


Before plunging into different methods of restriction of memory, it is necessary to know how the virtual memory of process is arranged. The best article on this subject — "Program anatomy in memory".

Having read article, I can offer two opportunities for memory restriction: to reduce virtual address space or amount of a heap.

The first: reduction of amount of address space. It is quite simple, but it is not absolutely correct. We cannot reduce all space to 1 MB — there will not be enough place for a kernel and libraries.

The second: reduction of amount of a heap. Not so just to make it, and usually so nobody does as it is available only through fuss with the binder. But for our task it would be more correct option.

Also I will consider other methods, such as tracking of use of memory through call intercept of libraries and system, and change of an environment of the program through emulation and introduction of "sandbox".

For testing we will use the small program for the name big_alloc placing, and then releasing 100 MiB.

Read more »


Compensation of errors at operations with numbers with floating comma

1 year, 10 months ago
Work is devoted to the rounding errors arising at calculations at numbers from floating comma. Here the following subjects will be briefly considered: "Representation of real numbers", "Ways of finding of rounding errors at numbers from floating comma" the example of compensation of rounding errors will also be given.

In this work examples are given in language of programiirovaniye of C.

Read more »